Forum Discussion
DAX Calculated Table
- Anonymous9 years ago
Hi Kroth,
>>1. Am I typing something wrong in the DAX to accomplish a Calculated Table with only the unique combinations of Dim1 and Dim2?
Based on my test, you have written the calculate table in the VAR function, the formula will been limiting calculate range(only work on current row).
>> 2. Does passing a calculated table in a Calculate() parameter filter as I am expecting?
Yes, it is possible.
I have modified your formula, please follow below steps:
1. Create table.
2. Modify your measure to match my table.
Test your calculate table formula: (It works well)
Measure = var fitler1 = CALCULATETABLE (
ADDCOLUMNS (
VALUES ( test[Column1] ),
"Column2", VALUES ( test[Column2] )
),
LastDate(test[Date]),
test[Column5] = TRUE)
return
Calculate(
SUM(test[Column2]),
fitler1
)
3. Add a calculate column to display the result.
It seems that filter ‘LastDate(test[Date])’ not work. Since you put the code of calculate table in the VAR function, the formula will been limiting calculate range on current row.
4. Modify your code to fix this issue.
Measure = var fitler1 = CALCULATETABLE (
ADDCOLUMNS (
VALUES ( test[Column1] ),
"Column2", VALUES ( test[Column2] )
),
LastDate(ALL(test[Date])),
test[Column5] = TRUE)
return
Calculate(
SUM(test[Column2]),
fitler1
)
Notice: The variable can store the table, but it can't get the columns directly, you can use filter or selectcolumns function to get columns which in the variable table.
Sample:
filter(filer1, [Column1] <> blank)
Regards,
Xiaoxin Sheng
Hi Kroth,
>>1. Am I typing something wrong in the DAX to accomplish a Calculated Table with only the unique combinations of Dim1 and Dim2?
Based on my test, you have written the calculate table in the VAR function, the formula will been limiting calculate range(only work on current row).
>> 2. Does passing a calculated table in a Calculate() parameter filter as I am expecting?
Yes, it is possible.
I have modified your formula, please follow below steps:
1. Create table.
2. Modify your measure to match my table.
Test your calculate table formula: (It works well)
Measure = var fitler1 = CALCULATETABLE (
ADDCOLUMNS (
VALUES ( test[Column1] ),
"Column2", VALUES ( test[Column2] )
),
LastDate(test[Date]),
test[Column5] = TRUE)
return
Calculate(
SUM(test[Column2]),
fitler1
)
3. Add a calculate column to display the result.
It seems that filter ‘LastDate(test[Date])’ not work. Since you put the code of calculate table in the VAR function, the formula will been limiting calculate range on current row.
4. Modify your code to fix this issue.
Measure = var fitler1 = CALCULATETABLE (
ADDCOLUMNS (
VALUES ( test[Column1] ),
"Column2", VALUES ( test[Column2] )
),
LastDate(ALL(test[Date])),
test[Column5] = TRUE)
return
Calculate(
SUM(test[Column2]),
fitler1
)
Notice: The variable can store the table, but it can't get the columns directly, you can use filter or selectcolumns function to get columns which in the variable table.
Sample:
filter(filer1, [Column1] <> blank)
Regards,
Xiaoxin Sheng