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:
- 8 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
That should me a MEASURE not a COLUMN
Production Measure = SUM ( 'Table'[Production] ) + 0
Then place the Measure in the Values area of your Line Chart.
That should do it! :smileyhappy:
Sean Oh man! It works, that's it for the monthly chart, thank you so much! :)