Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi All,
I am exploring nested calculate dax, out of this dax I was expecting only Audio Sales to be displayed but the filter context on Product Category is retained in Measure Calculates measures. Please may I have help understand what I am missing.
DataModel:
Solved! Go to Solution.
@han_rj The issue with your DAX formula is that the nested CALCULATE function does not work as expected because the inner CALCULATE does not return a scalar value that can be used in the outer CALCULATE
Try this
Measures =
VAR calc = CALCULATE([Sales Amount], 'Product Category'[Category] = "Audio")
RETURN calc
Proud to be a Super User! |
|
@han_rj
why you are using variable? variable scope is limited..
Just use CALCULATE([Sales Amount], 'Product Category'[Category] = "Audio")
Or
CALCULATE([Sales Amount],FILTER(ALL( 'Product Category'[Category] ),'Product Category'[Category] = "Audio") )
This is not the case of nested calculate.
Regards
sanalytics
Variables in DAX are not really variable, they are constants. They are only ever evaluated once, and then they do not change. So your calc variable is evaluated in the original filter context, and the subsequent CALCULATE has no effect on that.
Variables in DAX are not really variable, they are constants. They are only ever evaluated once, and then they do not change. So your calc variable is evaluated in the original filter context, and the subsequent CALCULATE has no effect on that.
@han_rj
why you are using variable? variable scope is limited..
Just use CALCULATE([Sales Amount], 'Product Category'[Category] = "Audio")
Or
CALCULATE([Sales Amount],FILTER(ALL( 'Product Category'[Category] ),'Product Category'[Category] = "Audio") )
This is not the case of nested calculate.
Regards
sanalytics
@han_rj The issue with your DAX formula is that the nested CALCULATE function does not work as expected because the inner CALCULATE does not return a scalar value that can be used in the outer CALCULATE
Try this
Measures =
VAR calc = CALCULATE([Sales Amount], 'Product Category'[Category] = "Audio")
RETURN calc
Proud to be a Super User! |
|
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
19 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |