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
Pvargash
Frequent Visitor

Replace empty cells with 0 matrix power bi

Hello community, help me with the following, I have the known problem of being able to replace empty cells with 0, I tried this first part using Coalpace and also Blank(), the problem with that is that in the categories and subcategories according to my model of data, values ​​with 0 appear in all categories (Unidad de Negocio) and subcategories (Nomcat) even if there is no Sales record for those categories, I only need to complete with 0 those cells that have at least had movements greater than 0 in any of the weeks.

 

I currently have sales only until the year 2022, until week 33

 

Pvargash_1-1659412774307.png

but when I add the formula to replace Empty with 0 the following happens to me, the other categories and subcategories are added and every week up to 53

 

GP =
VAR Total_GP = CALCULATE([Total_GP])
return
--Total_GP
IF (
Total_GP = BLANK(),
0,
Total_GP
)
Pvargash_6-1659413389856.png

 

Pvargash_2-1659412933478.png

This is my data model

Pvargash_4-1659413208831.png

 

3 REPLIES 3
Pvargash
Frequent Visitor

Thanks MahyarTF for the answer,

I have modified the formula, the number of weeks for 2022 is correct and it shows the values ​​but I still have gaps, in the weeks for certain categories and subcategories, those should be painted with 0

 

Pvargash_0-1659458624815.png

Now if I make the following change to the formula,

GP =
VAR Total_GP = CALCULATE([Total_GP])
return
--Total_GP
IF(
Not(isBlank(Total_GP)),
Total_GP,
0
)

it shows 0 for all the weeks which is correct, but it adds all the categories and subcategories that have not been sold and also adds all the weeks. I think there is a filter missing that indicates that I only need to limit sales of the current year and only of the weeks that I have to date, but I don't know how to do it

 

Pvargash_1-1659459271535.png

 

Would you please share a sample PBIX file with me here.

Mahyartf
MahyarTF
Memorable Member
Memorable Member

Hi,

Not sure, but maybe it is because you check the Blank value and replace it with 0.

Check the below script instead of yours :

GP =
VAR Total_GP = CALCULATE([Total_GP])
return
--Total_GP
IF (
Not(isBlank(Total_GP)),
Total_GP
)
Mahyartf

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.