Forum Discussion
Plot zero when there is no data in line chart
- 8 years ago
And same for the MovingAverage
MovingAverage = CALCULATE ( SUM ( 'Shiptracking history'[Production] ), DATESINPERIOD ( 'Shiptracking history'[Date], LASTDATE ( 'Shiptracking history'[Date] ), -10, DAY ) ) / 10 + 0Hope this helps! :smileyhappy:
Works with the sample data!
- 8 years ago
Okay hopefully this will solve it!
First things first go back to the Query Editor
1) Select the Date Column - Add Column tab - Time dropdown/button - select Time Only
2) with Date Column still selected - Date dropdown/button - select Date Only
3) Rename the original Date Column - Time and Date (or as you wish) and Date.1 rename just Date
4) Home tab - Close and Apply
Then
5) Create a Calendar Table - Modeling tab - click New Table
Calendar Table = CALENDAR ( MIN('Table'[Date]), MAX('Table'[Date]) )6) Set up the Relationship between the 2 tables based on the 2 date columns
7) And this is your New Moving Average Measure
MovingAverage Measure Calendar =
CALCULATE (
SUM ( 'Table'[Production] ),
DATESINPERIOD (
'Calendar Table'[Date],
LASTDATE ( 'Calendar Table'[Date] ),
-10,
DAY
)
)
/ 10
+ 08) You can add a "Between" Date Slicer if you wish just make sure you use the Date from the Calendar
9) Create a Line Chart - add the Date from the Calendar to the axis and deselect the Date Hierarchy if it defaults to it
10) Add the New Moving Average to the Values
Tell me this works! :smileyhappy:
- 7 years ago
Wrap the calculation in CALCULATE to have Row Context
Production Measure New = SUMX ( FILTER ( 'Calendar Table', 'Calendar Table'[Date] <= TODAY () ), CALCULATE ( SUM ( 'Table'[Production] ) + 0 ) )
Anonymous
Try these 2 things:
1) Right click on the date hierarchy in you axis and select - Show Items with No Data
2) Then add zero + 0 to the Measures that calculate the daily production
Let me know of this works! :smileyhappy:
- Anonymous8 years agoNot applicable
Sean thanks, it didn't work. I have provided more details in my post, in case that is helpful
- Sean8 years agoCommunity Champion
This response is from my phone. So I haven’t had a chance to try the sample data.
However you need to add zero to the aggregated amounts
Production+0 = SUM ( 'Shiptracking history'[Production] ) + 0
and same with the moving average :smileyhappy:
- Anonymous8 years agoNot applicable
Thanks! I might be not understanding what you mean... Check out what I get if I do what I think you mean. I get a very large number, I don't know where that number comes from!
That sum results in a large number which I don't recognise
The correct order of magnitude is ~0.7M, not 300M