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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Filters does not work when +0 is added to remove blanks

Hello, 

I need to visualize the last 12 months' data from a selected date, for that, I have created a date table(DTEntryDateTable) that is not connected with the fact table and used this measure to visualize 12-month data in the bar chart. 

 

 

Measure=
VAR CurrentDate = MAX(DTEntryDateTable[dteCreatedOn])
VAR PreviosData = DATE(YEAR(CurrentDate),MONTH(CurrentDate)-12,DAY(CurrentDate))
VAR Result = 

CALCULATE(
    COUNT(tblIndexDT[numIndexID]),
    
    FILTER(
        tblIndexDT,
        tblIndexDT[dteCreatedOn]>=PreviosData && tblIndexDT[dteCreatedOn]<=CurrentDate
    )
)
RETURN
Result

 

 

This measure works fine and it does the job, But I need to show blank values as "0", Therefore I changed the measure into this,

 

 

Measure=
VAR CurrentDate = MAX(DTEntryDateTable[dteCreatedOn])
VAR PreviosData = DATE(YEAR(CurrentDate),MONTH(CurrentDate)-12,DAY(CurrentDate))
VAR Result = 

CALCULATE(
    COUNT(tblIndexDT[numIndexID])+0,
    
    FILTER(
        tblIndexDT,
        tblIndexDT[dteCreatedOn]>=PreviosData && tblIndexDT[dteCreatedOn]<=CurrentDate
    )
)
RETURN
Result

 

 

But when I add +0 for the count, it ignores the filter in Dax and shows data for every month which is available in the dataset with zeros for blank values.

Please help me to figure out a way to show zeros for blank values without losing the filters in DAX.

Thank you.

2 ACCEPTED SOLUTIONS

Hi @Anonymous ,

 

Can you try the following DAX:

 

Measure=
VAR CurrentDate = MAX(DTEntryDateTable[dteCreatedOn])
VAR PreviosData = DATE(YEAR(CurrentDate),MONTH(CurrentDate)-12,DAY(CurrentDate))
VAR Result = 
CALCULATE(
    COUNT(tblIndexDT[numIndexID]),
    FILTER(
        tblIndexDT,
        tblIndexDT[dteCreatedOn]>=PreviosData && tblIndexDT[dteCreatedOn]<=CurrentDate
    )
)
RETURN
IF(ISBLANK(Result), 0, Result)

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

Hi, @Anonymous 

 

The data that was hidden by the blank value is now displayed as 0. You can add a date slicer to filter data from March 2023 to March 2021 or use filter pane to filter date column. 

 

Best Regards

Janey Guo

 

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

10 REPLIES 10
aggisss
Frequent Visitor

Hi,
have you solced this issue?
I have similar problem,
even if I add filter on a visual for offset month is not working.
Looks like function is blank, removes date filter.

v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

According to your description, Your formula is correct, but there is a problem with the result, So can you share some sample fake data and your visual result like? We need to judge the context.

 

Best Regards

Janey Guo

 

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

Anonymous
Not applicable

Hello Janey Guo,

Thank you for the response.😊

 

This is the output from the current measure,

Screenshot (376)_LI.jpg

Here I want to display zero for blanks

Details of above-mentioned matrix,

  1. Row - Statuses from a dimension table
  2. Column - A calculated column of months in YYYY-MM format
  3. Measure - Above mentioned measure to display last 12 months data.

Below is the data model,

 

Screenshot (377).png

Relationships,

  1. Status code relationship between tblIndexHD and CFIndexstatus
  2. Date relationship with date table (for the measure).

Thank you very much for your valuable time. 

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Try chnaging your measure to as follows:

Measure=
VAR CurrentDate = MAX(DTEntryDateTable[dteCreatedOn])
VAR PreviosData = DATE(YEAR(CurrentDate),MONTH(CurrentDate)-12,DAY(CurrentDate))
VAR Result = 

CALCULATE(
    COUNT(tblIndexDT[numIndexID]),
    
    FILTER(
        tblIndexDT,
        tblIndexDT[dteCreatedOn]>=PreviosData && tblIndexDT[dteCreatedOn]<=CurrentDate
    )
)
RETURN
Result + 0

 

Thanks,

Pragati 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Thank you @Pragati11  for your response,

But still, it does not work.

☹️

Hi @Anonymous ,

 

I guess then you will have to add more details on your data and calculations.

 

Thaks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hello Pragathi,

Thank you for the response.😊

 

This is the output from the current measure,

Screenshot (376)_LI.jpg

Here I want to display zero for blanks

Details of above-mentioned matrix,

  1. Row - Statuses from a dimension table
  2. Column - A calculated column of months in YYYY-MM format
  3. Measure - Above mentioned measure to display last 12 months data.

Below is the data model,

 

Screenshot (377).png

Relationships,

  1. Status code relationship between tblIndexHD and CFIndexstatus
  2. Date relationship with date table (for the measure).

Thank you very much for your valuable time. 

Hi @Anonymous ,

 

Can you try the following DAX:

 

Measure=
VAR CurrentDate = MAX(DTEntryDateTable[dteCreatedOn])
VAR PreviosData = DATE(YEAR(CurrentDate),MONTH(CurrentDate)-12,DAY(CurrentDate))
VAR Result = 
CALCULATE(
    COUNT(tblIndexDT[numIndexID]),
    FILTER(
        tblIndexDT,
        tblIndexDT[dteCreatedOn]>=PreviosData && tblIndexDT[dteCreatedOn]<=CurrentDate
    )
)
RETURN
IF(ISBLANK(Result), 0, Result)

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Thank you for the response @Pragati11 ,

But still, the problem is there, below is the faulty output,

Screenshot (380)_LI.jpg I want to show data only for the last twelve months(March 2021 to March 2020) with zero for blanks, but here it shows data for every month.

 

Hi, @Anonymous 

 

The data that was hidden by the blank value is now displayed as 0. You can add a date slicer to filter data from March 2023 to March 2021 or use filter pane to filter date column. 

 

Best Regards

Janey Guo

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.