Forum Discussion

MCMM's avatar
MCMM
Frequent Visitor
4 years ago
Solved

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:

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….

  • 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

    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.

3 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    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 ) )
    )
  • v-xiaotang's avatar
    v-xiaotang
    Icon for Community Support rankCommunity 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

    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.