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 ) )
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
+ 0
8) 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:
Hello Sean Sean , is there a way to do this if i have my date as "2018-01" format for example. i can format it as a date but its still not working for me.
thank you
heres a sample of the measure i created thus far