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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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 logo


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 logo


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

@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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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