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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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!:
DAX For Humans

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
Community Champion
Community Champion

@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!:
DAX For Humans

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!:
DAX For Humans

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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.