Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
LB19
New Member

DAX not doing what I expected

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.

 

Screenshot 2023-10-17 034019.png

 

 

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

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

Dangar332
Super User
Super User

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.