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
abriggs
Frequent Visitor

Dax IF Formula totals are incorrect?

I'm trying to write a measure that will pull through an amount if it's positive and to exclude the negatives. The dax IF formula is doing that for the guts of the data...but the total is not reflecting it... thoughts? I appreciate your help! 

 

abriggs_1-1605298237524.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@abriggs , if values need to be ignored at the row/line  level. Then try

Measure = CALCULATE(SUMX(filter('Table','Table'[Values] > 0),'Table'[Values]))

 

If the filter is after grouping data, say at account no
Measure = CALCULATE(SUMX(values('Table'[Account No]),if('Table'[Values] > 0, 'Table'[Values] , blank())))

View solution in original post

5 REPLIES 5
abriggs
Frequent Visitor

Sorry for my delay - it worked. Thank you!!! 

v-jingzhang
Community Support
Community Support

Hi @abriggs 

 

Has the problem been solved? If so, you may accept the appropriate post as the solution or post your own solution to help other members find it quickly. If not, can you please share some sample data or sample PBIX file so that we can try to find the targeted measures? Thanks very much.

 

Best Regards,

Community Support Team _ Jing Zhang

amitchandak
Super User
Super User

@abriggs , if values need to be ignored at the row/line  level. Then try

Measure = CALCULATE(SUMX(filter('Table','Table'[Values] > 0),'Table'[Values]))

 

If the filter is after grouping data, say at account no
Measure = CALCULATE(SUMX(values('Table'[Account No]),if('Table'[Values] > 0, 'Table'[Values] , blank())))

abriggs
Frequent Visitor

Hi! Thank you for your response. 

So what you've said makes sense and works when the values is not a previous calculated measure, else it's not working. 

When I recreated this.... my values is a prior calculated measures....thoughts?

Measure = CALCULATE(SUMX('Table','Table'[Values]),'Table'[Values] > 0)

 

FrankAT
Community Champion
Community Champion

Hi @abriggs 

you can try it like this (I used my own sample data):

 

13-11-_2020_21-26-35.png

 

Measure = CALCULATE(SUMX('Table','Table'[Values]),'Table'[Values] > 0)

Sum of Values = IF(SUM('Table'[Values]) <= 0 , 0 , [Measure])

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

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.