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
Opal55
Helper II
Helper II

Show zero on Line chart where no data for date

Hello all.  I am trying to build a line chart visual that will display Zero when no data is present.  I have been reading through the forum for some time and have tried multiple ways suggested and cannot get the chart to display the way I need.   I am tracking audits performed by shift.  On 03/16/21, the "Orange" shift did 1 audit and the "Blue" shift did none.  I do not want to see a gap in the line for the "Blue" shift, but rather have it drop down to zero on the X- Axis.

 

Opal55_0-1616528223843.png

The chart should look something like this:

Opal55_1-1616528344459.png

I am using the following as my Measure to calculate the Audit Count:

 

AuditCount = COUNT(Audits[AuditID])+0

 

My X-Axis is Categorical as I want to display all dates.  Changing to Continuous does not show the desired results as the Blue shift data line jumps from 03/15/21 to 03/17/21 and I do not want that.

Opal55_2-1616528484697.png

 

Any suggestions / support to resolve this would be appreciated.  Thank you.

2 ACCEPTED SOLUTIONS

@Opal55 

Ok, here is a true and tested way:

Create a measure along the lines of:

Cutoff = 
VAR _MaxDataDate = CALCULATE(MAX('Audits'[ShiftDate]), ALL('Audits'))
RETURN
IF(MAX('Calendar'[Date]) <= _MaxDataDate, 1) 

Now select the visual and add this measure to the "Filters on this visual" in the filter pane and set the value to 1. 

Use the proven [AuditCount] measure in the visual:

 

cutoff.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

@PaulDBrown as a follow-up to my reply yesterday, I came up with a different solution.  As well as yours worked, it did not work for what I need to show.  What I ended up doing is adding two calculated columns to my Audit Table.

CountO = If(Audits[Shift]="O",1,0)
CountB = If(Audits[Shift]="B",1,0)

and added them to my visual.  I got the chart and the matrix to display with zeros as I wanted and no unwanted dates.

Opal55_0-1617113805923.png

Opal55_1-1617113836366.png

Thank you for putting up with me.  🙂

 

View solution in original post

24 REPLIES 24

@PaulDBrown , so from my report, I have this measure:

Opal55_3-1616609568666.png

+ This measure:

Opal55_1-1616609392237.png

and my chart looks like this....  no change from above....😶

Opal55_2-1616609476941.png

 

 

@Opal55 

Ok, here is a true and tested way:

Create a measure along the lines of:

Cutoff = 
VAR _MaxDataDate = CALCULATE(MAX('Audits'[ShiftDate]), ALL('Audits'))
RETURN
IF(MAX('Calendar'[Date]) <= _MaxDataDate, 1) 

Now select the visual and add this measure to the "Filters on this visual" in the filter pane and set the value to 1. 

Use the proven [AuditCount] measure in the visual:

 

cutoff.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown as a follow-up to my reply yesterday, I came up with a different solution.  As well as yours worked, it did not work for what I need to show.  What I ended up doing is adding two calculated columns to my Audit Table.

CountO = If(Audits[Shift]="O",1,0)
CountB = If(Audits[Shift]="B",1,0)

and added them to my visual.  I got the chart and the matrix to display with zeros as I wanted and no unwanted dates.

Opal55_0-1617113805923.png

Opal55_1-1617113836366.png

Thank you for putting up with me.  🙂

 

Hi @PaulDBrown ... apologies for the delay in getting back to you... was getting pulled away from this project for a couple of days.  Now that I am back at it, I have tried your method, above and am getting better results.... 

Opal55_0-1617043276763.png

A few responses back you had told me to change the X-Axis to the Date field in the Calendar table.... but here's my dilemma... we don't work most weekends so I am getting Zero results for weekend dates because I have no data for these dates.  Is there a work-around for that?  

 

Here is my data in a matrix:

Opal55_1-1617043450914.png

So in the line chart visual, I want to show Zero for B shift on March 16, but I do not want to show any data for March 20 & 21 as we were not working... same for all other weekend dates in March.  But if I switch to show February, we did work on Feb 27, so would want to show that data in the line chart visual.  Does that make sense?

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.