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
usernameone101
New Member

Different Use Case | DAX Totals calculating incorrectly for measures

Hi All,

 

I know this is documented quite a few times throughout the forums and I assure you I have read through every one before making another post. The problem is that my use case involves calculating the total in a column of a table which potentially has two different tables in play (depending on the value of the row).

 

Heres the logic for how it decides which column from one of the tables to use.

 

RETURN
ROUND(
SWITCH(
TRUE(),
Var1, 0,
NOT Var2, Var3,
ISBLANK(Var3) && ISBLANK(Var4) && ISBLANK(Var5) && ISBLANK(Var6), 0,
Var7 IN {"x", "y", "z"}, 0,
Var8 && Var9 IN {"a", "b"}, Var10,
Var8 && Var9 IN {"c", "d"}, Var11,
Var4
),
2
)
 
I created an additional measure as advised by other forums to interpret this measure
 
I am able to successfully calculate the total for only 1 of each use case. i.e. if all 10 rows are only from one column than the total will be fine, if there is 5 from a and 5 from b then only a would show in the total for example (although the individual row values would be correct).
 
The additional measure uses this logic:
CALCULATE(
SUMX(
{0}, // Single-row table to iterate over
VAR Var1 = SUMX('Table1', [Var2])
VAR Var3 = SUMX('Table2', [Var2])
RETURN
IF(
ISBLANK(Var3),
Var1,
Var3
)
)
)
 
Am I doing something wrong? Or is this just impossible in DAX.
 
Thanks again for any help 🙂
usernameone101
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @usernameone101 

 

Try this :

 

Expected_Hours_Total2 = 
VAR SumTable1 = SUMX('Table1', [Expected_Hours])
VAR SumTable2 = SUMX('Table2', [Expected_Hours])
RETURN
IF(
    ISBLANK(SumTable1),
    SumTable2,
    SumTable1 + SumTable2
)

 

vnuocmsft_0-1739256411184.png

 

If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @usernameone101 

 

Try this :

 

Expected_Hours_Total2 = 
VAR SumTable1 = SUMX('Table1', [Expected_Hours])
VAR SumTable2 = SUMX('Table2', [Expected_Hours])
RETURN
IF(
    ISBLANK(SumTable1),
    SumTable2,
    SumTable1 + SumTable2
)

 

vnuocmsft_0-1739256411184.png

 

If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

usernameone101
New Member

Expected_Hours_Total2 =
VAR SumTable1 = SUMX('Table1', [Expected_Hours])
VAR SumTable2 = SUMX('Table2', VALUE('Table2'[Table2.Employee No]))
RETURN
IF(
    ISBLANK(SumExpectedHours),
    SumTable2s,
    SumTable1
). After digging more I found the issue is its only adding the total for Table1, not Table2. Unsure of the cause

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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