Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello Power BI Community,
I frequently find myself saving filters as VARs and then applying the variable using the CALCULATE function.
See below:
myExpression =
VAR testFilter = FILTER(table, table[column])
RETURN CALCUALTE(SUM(table[column]),testFilter)
And this works really well! However, I end up re-writing the same VARs for filters in other measures. I was wondering if there was a way to save these VARs and reuse them (possibly as a measure?).
Appreciate any and all help!
Solved! Go to Solution.
Hi @watkinbt ,
As FILTER function returns a table, so you cannot save it as a measure or column, but you can save it as a new table to solve your issue, like this:
1.Create a new table.
2.Create relationship.
3.Directly use the new table as a filter in your DAX.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @watkinbt ,
As FILTER function returns a table, so you cannot save it as a measure or column, but you can save it as a new table to solve your issue, like this:
1.Create a new table.
2.Create relationship.
3.Directly use the new table as a filter in your DAX.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @watkinbt
You can't create a myFilter measure as it'll through an error. You may try the calculation group in this case.
Hello @watkinbt
You don't need to use the filter. You can directly use the column within CALCULATE() without using FILTER().
MyExpression =
CALCUALTE( SUM( table[column] ), table[column1] = "Condition" )
I could, but this doesn't really solve the issue of re-writing the conditional statement over and over again.
It would be nice if I could change this in one place (like you can with a measure). Something like:
myFilter = FITLER(table,table[column]="condition")
To ultimately use the filter in multiple measures like this:
measure1 = CALCULATE(SUM(table[column]),myFilter))
measure2 = CALCULATE(SUM(table[column1]),myFilter))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |