cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mahi1827
Resolver I
Resolver I

How to show 0 dynamically in matrix when there is no data or blank in the direct query mode

Hi,

 

Here is how the data look like for scenario with some example and also copied sample pbx file link below

 

https://1drv.ms/u/s!AlARJq6xd5KedVlP0zJpo2xgG_s?e=tR2Okt

(product id is unique), please cehck sample file for more deatils.

sample data:

product status product service
open                 phase1
open                 phase1
open                  phase1
completed         phase 2
completed          phase 2
completed          phase 2
completed          phase 2

 

after adding data into matrix :

Product status         open    completed
product service
phase1                      3
phase2                                      4

 

in above example i would like show 0 when there is no data associated with rows and columns

my expected output like below:


Product status           open          completed
product service
phase1                       3                      0
phase2                       0                      4

 

rows iam using as product service , columns using as Product status and values given as count(product service)
here to avoid blanks i have used adding +0 in count(product service),tried with comparing length of the count.

 

I have tried with both measure1 and measure 2 show in sample pbix file but still i am not able to show 0 instead of blank values. 

 

Measure1 = CALCULATE(count(Sheet1[product service ])+0,Sheet1[product service ] in distinct(Sheet1[product service ]))
Measure2 = var blankcheck=calculate(count(Sheet1[product service ])) return if(blankcheck=blank(),0,blankcheck+0)
 

please check and suggest your ideas. Thank you.

 

Thanks

Mahi1827

 

1 ACCEPTED SOLUTION
Pragati11
Super User
Super User

Hi @Mahi1827 ,

 

Create 2 measures:

Completed =
var com = CALCULATE(COUNT(productTest[Product status]), productTest[Product status] = "completed")
RETURN
IF(com = 0, 0, com)
 
Open =
var op = CALCULATE(COUNT(productTest[Product status]), productTest[Product status] = "open")
RETURN
IF(op = 0, 0, op)
 
Then move these measure along with your Product service column on the matrix visual:
pt1.png
 
Thanks,
Pragati
 

Best Regards,

Pragati Jain

MVP logoDACertAzCert

LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

3 REPLIES 3
Pragati11
Super User
Super User

Hi @Mahi1827 ,

 

Create 2 measures:

Completed =
var com = CALCULATE(COUNT(productTest[Product status]), productTest[Product status] = "completed")
RETURN
IF(com = 0, 0, com)
 
Open =
var op = CALCULATE(COUNT(productTest[Product status]), productTest[Product status] = "open")
RETURN
IF(op = 0, 0, op)
 
Then move these measure along with your Product service column on the matrix visual:
pt1.png
 
Thanks,
Pragati
 

Best Regards,

Pragati Jain

MVP logoDACertAzCert

LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi Pragati,

 

This logic is working as expected.Thank you so much for your time and help on this.

 

Thanks,
Mahi

themistoklis
Super User
Super User

@Mahi1827 

 

Try adding zero at the end of the formula. Outside CALCULATE function

 

Measure1 = CALCULATE(count(Sheet1[product service ])+0,Sheet1[product service ] in distinct(Sheet1[product service ])) + 0

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors