Forum Discussion
Dates on a graph - continuous -adding a date dimension
- 9 years ago
OK solved
- what are we trying to achieve..show a value on a graph of zero, for days that have no data or events.
How to achieve ..basically ..create a list of all calender dates for the period of data in question and the left join that to your data
Note, there is a power query M function to create a list of dates List.Dates ( date dimension)
Note, start DATE in this case 2015,12,7, Determine your earliest date in your data.
This will create a list of dates with no future dates !
Step 1
in The query Editor create a blank query
and paste the below into the advanced editor.
let Source = #date(2015,12,7), #"Converted to Table" = #table(1, {{Source}}), #"Added Custom" = Table.AddColumn(#"Converted to Table", "Date", each List.Dates(Source, Number.From(DateTime.LocalNow())- Number.From(Source) ,#duration(1,0,0,0))), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Date"), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Custom",{{"Date", type date}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "Start Date"}}) in #"Renamed Columns"2) Query Editor create another query as the left outer join (merge ) your "Date" list column with a date in your data which has no data on some days.
3) Query editor create a custom column called 'Data Exists' with this formula, where ID is column can be null on some dates.
if [ID] is null then 0 else 1
4) change type to whole number. Must be a number or it dosen't work.
5) create a graph put "date" on the x-axis.
6) the column 'Data Exists' should have a sigma sign on meaning it is a number. Drag on the value axis and it will sum these.
Graph will now go to ZERO where there are gaps - SIMPLE ?
BEFORE
AFTER
Date Dimension table - Do you mean create a table of linear calender dates ? How would you do this. In excel you enter a date and drag column down and dump to a file but , this is alway problematic and how far into the futrue do you go.. or is there another way..in power bi ..ie create a date demension table - button..
Sure can! Have a read of this article.
http://www.agilebi.com.au/power-bi-date-dimension/
- ozmike9 years agoResolver I
Look promising! I will try it out next week unfortunately i have to go and if it flys you'll get credit..!
- ozmike9 years agoResolver I
Thanks got the list of date now what? any ideas..?
Hi I was able to invoke the function to create the list of dates. I tried to do an outer join from the date list to the data . seems to work. I have a data in the 2030s in the data , but if I do a measure in the visual and do a max I only get 2017 where the data ends.
Also if I do a graph dosen't show any data in the 2030s..not sure where to go form here...
- Anonymous9 years agoNot applicable
You could create a calculated column in your new date table, that is a simple On/Off switch for future dates. Something like:
isFuture = IF( [Date] > TODAY(), TRUE(), FALSE() )
You could add a filter into your report filters that only shows when isFuture = False