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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
atult
Advocate I
Advocate I

Calculate Sum of Column 1 only if Column 2 is not blank

Hello Experts,
Data:

 

atult_3-1661176199533.png

 

Expected Result:
- Calculate sum of Sales only if Units is not blank
- Sales Sum = 10 + 20 + 40 = 70; Sales = 30 for XYZ is skipped since Units is blank for it

 

I'm using below dax in calculated measure but it is not working:

Total Sales = IF(SUM('Sales_Table'[Units]) = BLANK(),BLANK(),SUM('Sales_Table'[Sales]))
2 ACCEPTED SOLUTIONS

@atult This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Anand24
Super User
Super User

Hi @atult ,
Try below dax:

Total Sales = 
CALCULATE(
    SUM('Sales_Table'[Sales]),
    'Sales_Table'[Units] <> BLANK()
)

For ease of Filtered Measure DAX, you can directly go to quick measure -> filtered value and then change your dax accordingly. 

 

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

View solution in original post

6 REPLIES 6
Anand24
Super User
Super User

Hi @atult ,
Try below dax:

Total Sales = 
CALCULATE(
    SUM('Sales_Table'[Sales]),
    'Sales_Table'[Units] <> BLANK()
)

For ease of Filtered Measure DAX, you can directly go to quick measure -> filtered value and then change your dax accordingly. 

 

PBI_SuperUser_Rank@1x.png  

Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

Proud To Be a Super User !!!
LinkedIn

Greg_Deckler
Super User
Super User

@atult Perhaps try this:

Total Sales = IF(SUM('Sales_Table'[Units]) <= 0,BLANK(),SUM('F_ORDERED Sales_Table'[Sales]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,
The total for Total Sales is still considering Sales value of XYZ:

atult_0-1661176895640.png

 

@atult This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler ,
Tried the below but not helping:

Total Sales = 
IF(
    HASONEFILTER(Sales_Table[Category]),
    IF(
        SUM(Sales_Table[Units]) = BLANK(),0,SUM(Sales_Table[Sales])
        ),
        SUMX(
            FILTER(Sales_Table,
            [Units]>1000
            ),
        [Sales]
        )
)

@atult Keep your original measure. Create a new measure:

Total Sales = 
IF(
    HASONEFILTER(Sales_Table[Category]),
    [Original Measure],
    SUMX(SUMMARIZE('Table',[Category],"__Sales",[Original Measure]),[__Sales])
)

For Measure Totals to work, you have to summarize or summarizecolumns or groupby your data exactly as it is in the visual and then use an X aggregator across that summarized table.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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