I have a table C with a LOOKUPVALUE column from table A and another LOOKUPVALUE column from table B.
I would like to add another column, which is the sum of the two columns.
When I try to use a DAX Sum formula, I get error: The SUM function only accepts a column reference as an argument.
I tried to demonstrate visually what I am trying to do here :Visual of my problem
Instead of your measure/column-
TOTAL = SUM(TOGETHER(BATMAN) + TOGETHER(ROBIN))
Can you please try with -
TOTAL = TOGETHER(BATMAN) + TOGETHER(ROBIN)
Note: Guess BATMAN and ROBIN both are custom columns in your table
Related
I am super new to power bi and Dax and i need to create a calculated column in which i have the total sales for each country respectively.
Here is a screenshot with an oversimplified scenario but if i can do it for this data i can do it in my actual project since the concept is the same.
The column TotalSalesPerCountry is the calculated column.
And here is what the column should look like if it worked. (Colors are just for visual representation)
Basically everywhere you see the same country you should see the same TotalSalesPerCountry values which are calculated by sum-ing the Sales for those countries over the years.
Another DAX function:
= CALCULATE(SUM(CountrySales[Sales]), FILTER(CountrySales, CountrySales[Country] = EARLIER (CountrySales[Country])))
This is simple to do in DAX. Add the column:
TotalSalesPerCountry =
var curCountry = yourTable[Country]
return CALCULATE(SUM(Sales), FILTER(yourTable, curCountry = yourTable[Country]))
Explanation:
For each row in the table, get the country. Filter yourTable on the curCountry and SUM this together).
im struggling with the following problem. I have categorical variables and and Amount column. What I want to do is, to write a dax measure which calculates the moving/rolling Sum, like you see in the third column "Dax Measure". Did not find any inhouse Dax function for that.
moving sum
EDIT:
Result Table with Dax Measure
Source Table
This will work if the category is always sorted ASC.
Dax measure =
VAR _currentRank = RANKX(ALL('Table'[Category]),CALCULATE(MIN('Table'[Category])),,ASC)
RETURN
CALCULATE(
CALCULATE(SUM('Table'[Amount]),TOPN(_currentRank,VALUES('Table'[Category]),MIN([Category]))),
ALL('Table'[Category])
)
Using RANKX to define the other and aggregating for all the item before it.
I'm having some issue regarding the filtering in Power BI/DAX. I have an example below. What I'm trying to achieve is to write a measure to filter out the rows where column 1 is "A" and Column 2 is "aa" and then sum the total of the rest of rows.
Thanks in advance!
You can use CALCULATE like this:
Sum of Filtered Values =
CALCULATE(
SUM('DataTable'[Amount]);
'DataTable'[Column1] = "A";
'DataTable'[Column2] = "aa"
)
The two rows below SUM() are filter arguments in the CALCULATE function. Each of the arguments removes all other filtering on their respective columns and then CALCULATE generates a table where the two filter arguments are combine with a logic AND, hence CALCULATE will SUM all [Amounts] where [Column1] is "A" and [Column2] = "aa".
This is basic DAX workflow. Read about CALCULATE, understand how the filter functions work (and their inherrent pitfalls), and learn to love it.
I'm trying to get a sum of my sales figures by the product category from the a column in the same table
The original data is on the attached image.
Original Data
And what I'm trying to get is attached also and I am having trouble getting the right numbers for the last three columns
Result
I have tried the following code:
Boots_Sales = CALCULATE( SUM(Sheet1[Sales]), FILTER(Sheet1,Sheet1[Product_Type]="Boots"))
I have found a solution to the above by making a measure instead of a column with the below formula:
boot1 = CALCULATE(SUM(original[Sales]),FILTER(original,original[Product type ]="Boots"))
This will have to do, I was trying to make a column because I wanted to do further calculations on the column but will just have to convert the measure into a column
Thanks
I am new to Power BI - DAX functions.
I have three columns in a table with text in it and I have added a fourth column where I want the count of these three but when I use COUNTA, COUNTX or COUNTAX measure I am getting the count of the entire column.
COUNTA
COUNTAX
COUNTX
Column = COUNTX(Table1, Table1[First_Amendment])
+ COUNTX(Table1, Table1[Second_Amendment])
+ COUNTX(Table1, Table1[Third_Amendment])
Suppose column A, B, C contains three names, apple, mango, oranges respectively so in fourth column I should get count as 3.
Did you want to count no blank column based on row, right?
If so, you could try to use calculated column like below
Column = if((countaa[a])="",0,1)+if((countaa[b])="",0,1)+if((countaa[c])="",0,1)
You also could refer to this post for details.
Zoe