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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply

Show 0 instead of blank when there is no record in the table

Hello, 

I am working on a requirement where I need to show '0' instead of blank (when there is no record in the dataset). Here is the sample data set.

StudentCourseScore

AMaths50
AScience40
BScience40
BHistory30
CMaths60
CSocial20

I need to show this data in a matrix visual where if there is a blank I need to show '0'.

Srikanth7Gunnam_0-1696404271317.png

Expected Result:

Srikanth7Gunnam_1-1696404321906.png

Could you please let me know how this can be done?

1 ACCEPTED SOLUTION

Hi @Srikanth7Gunnam 

You can create a calculated table first

Table 2 = var a=SUMMARIZE('Table',[Student])
var b=SUMMARIZE('Table',[Course])
return GENERATE(a,b)

Then create a measure

Measure =
VAR a =
    CALCULATE (
        SUM ( 'Table'[Score] ),
        FILTER (
            'Table',
            [Student]
                IN VALUES ( 'Table 2'[Student] )
                    && [Course] IN VALUES ( 'Table 2'[Course] )
        )
    )
RETURN
    IF ( a <> BLANK (), a, 0 )

Finally, put the field of table 2 and the measure to the matrix, the put the field of table2 to the slicer

Output

vxinruzhumsft_0-1696575135434.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

12 REPLIES 12
audreygerred
Super User
Super User

Try this trick

https://dataap.org/blog/2022/06/14/power-bi-replace-blank-with-0-matrix-visual/#:~:text=To%20replace...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you!! mlsx4 shared the same trick. It is working but filtering is not working. For instance, if I have slicers from the base table it is not filtering the courses. All the columns are showing with 0's. Any idea how to fix it?

Hi @Srikanth7Gunnam 

You can create a calculated table first

Table 2 = var a=SUMMARIZE('Table',[Student])
var b=SUMMARIZE('Table',[Course])
return GENERATE(a,b)

Then create a measure

Measure =
VAR a =
    CALCULATE (
        SUM ( 'Table'[Score] ),
        FILTER (
            'Table',
            [Student]
                IN VALUES ( 'Table 2'[Student] )
                    && [Course] IN VALUES ( 'Table 2'[Course] )
        )
    )
RETURN
    IF ( a <> BLANK (), a, 0 )

Finally, put the field of table 2 and the measure to the matrix, the put the field of table2 to the slicer

Output

vxinruzhumsft_0-1696575135434.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

mlsx4
Memorable Member
Memorable Member

Hi @Srikanth7Gunnam 

 

You can use a var and then, check with a condition

 

 

Measure= 

var score= SUM(MyTable[Score])

return if(ISBLANK(score),0,score)

 

Or if I'm not wrong, you can add a "+0" to the formula

 

Measure= SUM(MyTable[Score])+0

 

 

Thank you for your response!!

I have tried both ways before but it is not giving me the expected result. If you are getting the expected result, could you please share the pbix file?

Ok, sorry @Srikanth7Gunnam . I think it would work. I have tried now and it is not working. Then, you should do the following approach:

 

1) Create a new table with the Courses: 

CourseTable= VALUES(MyTable[Course])
 
2) Now, create the measureMeasure= SUM(MyTable[Score])+0 

 

 

Measure= SUM(MyTable[Score])+0

 

3) And then, in the matrix use for the column "Courses" but from the CoursesTable

mlsx4
Memorable Member
Memorable Member

Hi @Srikanth7Gunnam!! Did it work?

Hello, Thank you!! It did work but filtering is not working. For instance, if I have slicers from the base table it is not filtering the courses. All the columns are showing with 0's. Any idea how to fix it? 

Hi @Srikanth7Gunnam 

 

Filtering is working (if you select History, it will only show B which is the one with value <>0), but the thing is that Power Bi doesn't show a value when it is null (or blank, which is the same). 

Yes, filtering is working but it is showing the courses with 0 when it is filtered. Here is an example.

Dataset:

StudentCourseScoreClass

AMaths50Class A
AScience40Class A
BScience40Class A
BHistory30Class B
CMaths60Class A
CSocial20Class A

I have built a visual like below based on the above data and has a Class slicer. When nothing is selected it is shown like this

Srikanth7Gunnam_0-1696532214872.png

But, when Class A is selected it shows History course as well with 0's 

Srikanth7Gunnam_1-1696532285701.png

Here is the expected result I am looking for 

Srikanth7Gunnam_2-1696532334763.png

Can you please help me with this?

 

 

Hello @Srikanth7Gunnam ,

 

can you share the result you're having which not matches your need.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin
Vote for my Community Mobile App Idea 💡



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hello, thank you for your reply. Yes, I have shared it in my original question. Could you please check ?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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