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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Replace Blanks with 0

Hello,

 

I have a long if statement being used as a count in a matrix figure. I would very much like the blanks to be zeros. Everything I have tried has come up short. Thanks in advance for any assistance.

 Capture.PNGCapture.PNG

 

 

 

7 REPLIES 7
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

As BraneyBI said, "The problem is that for each intersection of your matrix where you want to show the 0, there are NO ROWS in your table with the correct filter context.". So, the workaround I suggest is inserting rows for each ACCT_STATUS per date range.

 

After adding the calculated columns with above long if statement, please create calculated tables as below:

Not-Worked_1 =
CROSSJOIN (
    VALUES ( 'Not-Worked'[Acct Status] ),
    VALUES ( 'Not-Worked'[Days in Status] )
)

1.PNG

 

Not-Worked_2 =
UNION (
    'Not-Worked',
    SELECTCOLUMNS (
        'Not-Worked_1',
        "Acct Status", 'Not-Worked_1'[Acct Status],
        "Days in status", 'Not-Worked_1'[Days in Status],
        "Value", 0
    )
)

2.PNG

 

Drag corresponding fields from 'Not-Worked_2' to Matrix visual.

3.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hey @v-yulgu-msft

 

Thanks for the reply. When I attempt what you have suggested I get the following error.

 

Capture.PNG

 

Do you see any errors in my formula or do you have a guess as to why this error is occuring?

 

Thanks

danextian
Super User
Super User

Hi @Anonymous

 

Does actual source really look like that? Or is it something like below?

 

Acct StatusDays RangeMeasure
A0-1 days45
B2-3 days42
C4 - 10 days36
D10-15 days12
E0-1 days37
A0-1 days1
B2-3 days11
C10-15 days42
D10-15 days38
E2-3 days7









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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Hey @danextian

 

Yes. My data has many rows of the ACCT_STATUS their corresponding Days in Status value.

@Anonymous

 

Hi, I reccomended to use DAX Formater to format your code.

 

http://www.daxformatter.com/

 

Will be more easy to understand it.

 

Regards

 

Victor




Lima - Peru
BraneyBI
Kudo Commander
Kudo Commander

This one is tricky.  The problem is that for each intersection of your matrix where you want to show the 0, there are NO ROWS in your table with the correct filter context.  I have a hack which will work, but requires a little formatting trickery. 

 

Based on your picture below, it appears your table is called 'Not-Worked'

In a Different table (I usually use Date), create a measure

      ShowZero = Calculate(.001, ALL('Not-Worked'))

 

It is important that you DO NOT PUT IT IN YOUR 'Not-Worked' table.

 

Add this value to your original measure 

 

     OriginalMeasure = IF(REALLY LONG DAX HERE...) + ShowZero

 

This will add the really small number to your measure, which when formatted without decimals, will show a ZERO!  This works because of the ALL() function which removes any filter context coming from the  'Not-Worked' table.

Anonymous
Not applicable

Hey @BraneyBI

 

When I attempted your work-around I got the following error

 

Capture.PNG

 

Here is my ShowZero Measure

 

Capture.PNG

 

Any thoughts?

 

Thank you

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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