The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello all,
I was reviewing some POWER BI fundamentals, and DAX is not doing what I was taught.
I wonder if CALCULATE was changed?
Shouldn't I be getting the same number for every line under OtherCosts?
Thank you.
Solved! Go to Solution.
HI @LB19,
For measure expression, you haven't add a function to expand the current row contexts so it work as a filter to only calculate when the current row context match with the condition.
Row Context and Filter Context in DAX - SQLBI
BTW, you can try to use the following measure formula if it helps:
othercosts =
VAR idList =
CALCULATETABLE (
//replace this to the relationship key between storedetails and costandtarget table
VALUES ( storedetails[ID] ),
FILTER ( ALLSELECTED ( storedetails ), storedetails[store] = 40 )
)
RETURN
CALCULATE (
SUM ( costandtarget[rent] ),
FILTER ( ALLSELECTED ( costandtarget ), costandtarget[ID] IN idList )
)
Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT - SQLBI
Regards,
Xiaoxin Sheng
HI @LB19,
For measure expression, you haven't add a function to expand the current row contexts so it work as a filter to only calculate when the current row context match with the condition.
Row Context and Filter Context in DAX - SQLBI
BTW, you can try to use the following measure formula if it helps:
othercosts =
VAR idList =
CALCULATETABLE (
//replace this to the relationship key between storedetails and costandtarget table
VALUES ( storedetails[ID] ),
FILTER ( ALLSELECTED ( storedetails ), storedetails[store] = 40 )
)
RETURN
CALCULATE (
SUM ( costandtarget[rent] ),
FILTER ( ALLSELECTED ( costandtarget ), costandtarget[ID] IN idList )
)
Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT - SQLBI
Regards,
Xiaoxin Sheng
hi, @LB19
try below
othercosts =
calculate(sum(costandtarget[rent]),storedetails[store]=40,removefilters(storedetails[store]))
Thank you.
It did not work but it made me realize what was wrong haha.
It's good now.
ok
if you get solution then let me know .
i will learn from that
User | Count |
---|---|
26 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
28 | |
13 | |
12 | |
12 | |
6 |