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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
markblom
Frequent Visitor

Show 0 instead of blank

Hi,

 

I would like to show 0's instead of blanks in a table showing sales and purchases for products. I have created a dummy report to show what issue I am running into. 

 

The dummy report has 3 tables:

  • Products: Product
  • Sales: Product, Date, Quantity
  • Purchases: Product, Date, Quantity

I have created to measures:

  • Sum of Purchases = CALCULATE(SUM(Purchases[Quantity]))
  • Sum of Sales = CALCULATE(SUM(Sales[Quantity]))

I created a table with three columns:

  • Product
  • Sum of Purchases
  • Sum of Sales

Below you will find a screenshot of the outcome:

In the middle table only the products are shown that have a purchase of sales. But for product C, the sales column is blank. Here, I would like to display 0.

 

I then tried another measure:

  • Sum of Sales Zero = CALCULATE(SUM(Sales[Quantity])) + 0

The table on the right show the outcome with that column. Now it shows 0's but now all products are shown in the table.

 

What can I do to only show products that either have sales or purchases with the value 0 instead of a blank?

markblom_0-1714745265853.png

 

Regards,

 

Mark

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@markblom Try:

Sum of Sales Zero =
  VAR __Result = IF( [Sum of Purchases] = BLANK() && [Sum of Sales] = BLANK(), BLANK(), SUM(Sales[Quantity]) + 0
RETURN
  __Result

Also, there is no reason for your CALCULATE statements wrapping your SUM functions


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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
markblom
Frequent Visitor

Thanks, that works!

Greg_Deckler
Super User
Super User

@markblom Try:

Sum of Sales Zero =
  VAR __Result = IF( [Sum of Purchases] = BLANK() && [Sum of Sales] = BLANK(), BLANK(), SUM(Sales[Quantity]) + 0
RETURN
  __Result

Also, there is no reason for your CALCULATE statements wrapping your SUM functions


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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors