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

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.

Reply
MCMM
Frequent Visitor

IF() DAX not working

Hi,

 

We are facing a really simple issue with IF() Dax. What we are trying to achieve is IF (A=0, B, A). For that, we created 3 measures:

A= amount for previous month

B = amount for before previous month

Last Closed Month = IF(A=0,B,A)

 

As you can see in the image below, both A and B measures work correctly, but the last closed month is retrieving A+B:

MCMM_0-1651741477402.png

We tried to change the logic to =BLANK(), =””,<>0, <>BLANK()… but no matter what we do, the last measure keeps summing A+B.

Are we missing something here? We have never faced this issue with an IF statement before….

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @MCMM 

The if function in table visual is fine, it is working properly. If you don't want the total in the total row, you can either turn it off or use hasonevalue() or hasonefilter() or isfiltered() to customize the value in the total

vxiaotang_1-1654250010744.png

vxiaotang_2-1654250128841.png

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @MCMM 

The if function in table visual is fine, it is working properly. If you don't want the total in the total row, you can either turn it off or use hasonevalue() or hasonefilter() or isfiltered() to customize the value in the total

vxiaotang_1-1654250010744.png

vxiaotang_2-1654250128841.png

Best Regards,

Community Support Team _Tang

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

tamerj1
Super User
Super User

Hi @MCMM 
What do you mean by (keeps summing)? If your problem is with the wrong total then you may try

Last Closed Month =
SUMX (
    SUMMARIZE ( DateTable, DateTable[Year], DateTable[Month] ),
    CALCULATE ( IF ( A = 0, B, A ) )
)
TOK
Helper II
Helper II

Hi @MCMM,

well the total row uses your logic on its aggregation. As A Total > 0, it will take A Total for Last Closed Month Total as your if statement says.

Can you upload your file?

Liked this post? More Content on:
https://www.youtube.com/channel/UC2lAgCgfyLCHsRv0h-ETBWQ

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors