cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RichardV
Advocate II
Advocate II

Dax: blank values +0 formula

Hi guys,

 

I was wondering if somebody could help me. It is concerning a PBI report with 2 visualisations, and I am working with an SSAS tabular model.

 

Visualisation 1: line graph with date (by day) on the X axis, and amount of files on the Y axis (last 3 years)

Visualisation 2: line graph with months on the X axis, amount of files on the Y axis and years as legend. (last 3 years)

 

Question:

 

I wanted to have a "0" instead of "blank" value for visual 1. That way, I can see for each data if there was one or multiple files per day. Therefore, I used the DAX formula "Measure = [amount of files] + 0", which works great for visualisation 1.

 

However, If I am using this formula for visualisation 2, it shows a line at "0" at november and december 2017. This I do not want to see, because this is a future date with no values.

 

Is there a DAX formula to make a measure to show a "0" for a blank value for each date earlier than today, but which is showing blank values for future days?

 

Help is appreciated, because I am not yet that savvy with DAX. Also keep in mind that the DAX formula should not include creating a calculated column, because I want to make the measure on top of an SSAS tabluar model.

 

Many many thanks in advance!!!

 

Richard

2 ACCEPTED SOLUTIONS
v-yulgu-msft
Microsoft
Microsoft

Hi @RichardV,

 

You can use IF condition in your measure like:

Measure = IF(MAX(Table[Date].[MonthNo])<=MONTH(TODAY()),[amount of files]+0,BLANK())

Remember to enable 'Show items with no data' on chart axis.

1.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.

View solution in original post

Hi @RichardV,

 

So, currently, with this formula Measure= IF(MAX('Table'[Date])>DAY(TODAY()) . [Amount of files]+0, BLANK()), you can always achieve the desired result, right?

 

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.

View solution in original post

4 REPLIES 4
v-yulgu-msft
Microsoft
Microsoft

Hi @RichardV,

 

You can use IF condition in your measure like:

Measure = IF(MAX(Table[Date].[MonthNo])<=MONTH(TODAY()),[amount of files]+0,BLANK())

Remember to enable 'Show items with no data' on chart axis.

1.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.

Hi @v-yulgu-msft,

 

Thanks a lot for your comment.

 

However, it deed not seem to work. Perhaps it has to do with the fact that I don't have the function with "show items with no data' because I create a measure on top of a SSAS tabular model.

 

The strangest thing is, that I tweaked a little with the formula, and I have seem to make it work. Unfortunately, I do not have an idea why this works.

 

The only thing that I did, is change "<=" into ">". So the formula becomes:

 

Measure= IF(MAX('Table'[Date])>DAY(TODAY()) . [Amount of files]+0, BLANK())

 

I don't have an explanation for why this works. Can I use this safely, or is there any error in this?

 

Best,

 

Richard

Hi @RichardV,

 

So, currently, with this formula Measure= IF(MAX('Table'[Date])>DAY(TODAY()) . [Amount of files]+0, BLANK()), you can always achieve the desired result, right?

 

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.

Yes, although no idea why it works

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!