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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
orlandom
Advocate I
Advocate I

How to show zeroes in a matrix (+0 is not working)

Hi,

 

I'm trying to show percentages and integer values in a matrix. I'm using the following measure to format the results:

Format for Summary = 
IF(HASONEVALUE(Summary_Region_Price[Category]),
	IF(VALUES(Summary_Region_Price[Category]) = "Percent",
		FORMAT(SUM(Summary_Region_Price[Total]), "0.0%"),
		FORMAT(SUM(Summary_Region_Price[Total]), "0")
	   )
)

Obviously, the measure above is showing BLANK when the results are blank. So I tried this:

 

Format for Summary = 
IF(HASONEVALUE(Summary_Region_Price[Category]),
	IF(VALUES(Summary_Region_Price[Category]) = "Percent",
		FORMAT(SUM(Summary_Region_Price[Total]) + 0, "0.0%"),
		FORMAT(SUM(Summary_Region_Price[Total]) + 0, "0")
	   )
)

But is still showing blanks...

Any ideas?

1 ACCEPTED SOLUTION

Got it!!!!

I was able to solve the issue with this formula:

Format for Summary Table = 

VAR H1V = HASONEVALUE(Summary_Region_Price[Category])
VAR Total = SUM(Summary_Region_Price[Total])
VAR Final_Total = IF(OR(ISBLANK(H1V), ISBLANK(Total)), 0, IF(H1V, Total, BLANK()))
VAR Current_Category = CALCULATE(SELECTEDVALUE(Summary_Region_Price[Category]),
                                 ALLEXCEPT(Summary_Region_Price, Summary_Region_Price[Category]))
RETURN

IF(Current_Category = "Percent", FORMAT(Final_Total, "0.0%"), FORMAT(Final_Total, "0"))


Thanks for your time @v-chuncz-msft and @prateekraina!!!

View solution in original post

14 REPLIES 14
v-chuncz-msft
Community Support
Community Support

@orlandom,

 

Add a calculated table and create relationship on [Region], then drag [Region] from this table to Columns. You'll find the difference for HASONEVALUE ( Summary_Region_Price[Category] ).

 

Table =
DISTINCT ( Summary_Region_Price[Region] )

 

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@prateekraina, Thanks a lot for the time you put into this.

@v-chuncz-msft, I didn't think about this, this is brilliant. Now I understand why I have my problem: Since the table is empty, HASONEVALUE is returning BLANK.

 

Unfortunately, I still don't know how to solve my problem, since I need to access the Category from the matrix to format the zero.

I was thinking something along the lines of:

Format for Summary Table = 

VAR H1V = HASONEVALUE(Summary_Region_Price[Category])
VAR Total = SUM(Summary_Region_Price[Total])
VAR Final_Total = IF(ISBLANK(H1V), 0, IF(H1V, Total, BLANK()))
RETURN

IF(SELECTEDVALUE(Summary_Region_Price[Category]) = "Percent",
    FORMAT(Final_Total, "0.0%"),
    FORMAT(Final_Total, "0")
)

Obviously, this approach doesn't work since SELECTEDVALUE is returning blank when the table is empty.

Got it!!!!

I was able to solve the issue with this formula:

Format for Summary Table = 

VAR H1V = HASONEVALUE(Summary_Region_Price[Category])
VAR Total = SUM(Summary_Region_Price[Total])
VAR Final_Total = IF(OR(ISBLANK(H1V), ISBLANK(Total)), 0, IF(H1V, Total, BLANK()))
VAR Current_Category = CALCULATE(SELECTEDVALUE(Summary_Region_Price[Category]),
                                 ALLEXCEPT(Summary_Region_Price, Summary_Region_Price[Category]))
RETURN

IF(Current_Category = "Percent", FORMAT(Final_Total, "0.0%"), FORMAT(Final_Total, "0"))


Thanks for your time @v-chuncz-msft and @prateekraina!!!

Hi all!

It is very interesting theme for me to.
But after implementation this formula I was not be able to return zero instead blank:
Left table - before, right - after implantation:

 

Blank_Cells.png

 

what the guess?

@MC

 

You missed the step mentioned by @v-chuncz-msft.

 

"

Add a calculated table and create relationship on [Region], then drag [Region] from this table to Columns. You'll find the difference for HASONEVALUE ( Summary_Region_Price[Category] ).

 

Table =
DISTINCT ( Summary_Region_Price[Region] )

"

 @prateekraina

i haven't unfortunately understand how this step help to resolve blank cells in the table. May be can you show on real example THIS?

Thank you in advance.

prateekraina
Memorable Member
Memorable Member

You should comare using BLANK(). Something like this:

IF( Summary_Region_Price[Category] = BLANK(), Do This, Do That)

 

It is not actual code. Just giving you context of how to use BLANK(). 

Thanks @prateekraina,

 

Tried this and is not working:

Format for Summary Table = 
  IF(HASONEVALUE(Summary_Region_Price[Category]), 
	 IF(VALUES(Summary_Region_Price[Category]) = "Percent", 
	  IF(SUM(Summary_Region_Price[Total]) = BLANK(), "0.0%", FORMAT(SUM(Summary_Region_Price[Total]), "0.0%")), 
	  IF(SUM(Summary_Region_Price[Total]) = BLANK(), "0", FORMAT(SUM(Summary_Region_Price[Total]), "0"))
	    )
     )



 

Can you provide some 10 sample rows of your data.

The data is shown below and for the purpose of the measure you can assume the name of the table is Summary_Region_Price.

The structure of the matrix is as follows:
Rows: Category, Price Range
Columns: Region
Values: The measure I showed in the question 

 

CategoryPrice RangeRegionTotal
PercentPR1R10.062827
PercentPR1R20.085616
PercentPR1R30.054533
PercentPR1R40.017602
PercentPR2R10.128272
PercentPR2R20.226027
PercentPR2R40.044004
TotalPR1R124
TotalPR1R250
TotalPR1R380
TotalPR1R416
TotalPR2R149
TotalPR2R2132
TotalPR2R440

Thanks.

 

Can you give me data for below scenario also as you mentioned earlier:
"Obviously, the measure above is showing BLANK when the results are blank"

 

I am not getting blank in matrix as per the data you provided.

 

Solution1.PNG

Put the Price Range column in the Rows section of the matrix and expand the rows. You should have blanks for the price range PR2 and the region R3.

 

See below:
Blanks in MatrixBlanks in Matrix

 

@prateekraina, any updates?

Appreciate very much your help.

I was on it whole night buddy. No work around yet 😞

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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