Forum Discussion

Lindserke's avatar
Lindserke
Regular Visitor
6 years ago
Solved

create empty dates / hours

Hi, 

 

i'm quite new to Power BI, and i'm not really finding the right subject on the internet to help me.

I have a large set of data, and would like to transform it as follows

 

AS IS:

01/01/2018 08:01:05

01/01/2018 08:05:17

01/01/2018 08:08:56

01/01/2018 08:17:45

01/01/2018 09:01:43

 

TO BE

01/01/2018 - 08:00:00 - 3

01/01/2018 - 08:15:00 - 1

01/01/2018 - 08:30:00 - 0

01/01/2018 - 08:45:00 - 0

01/01/2018 - 09:00:00 - 1

 

Basically, i want to do 2 things:

1/ group data by 15 minutes (I already managed that by adding a new colon "kwartuur", and then merging "hour" with "Kwartuur")

2/ but I cannot figure out how to create the date/hour that is missing in the basic data set (8:30).

 

i tried to create a calendar and a time calendar, but from there, how am i supposed to merge both data sets?

 

Thanks in advance for you feedback !

 

  • i've found a bit of a solution :)!

     

    for those who have the same issue as me, I did the following

    - create date calendar: 

    https://kohera.be/blog/power-bi/how-to-create-a-date-table-in-power-bi-in-2-simple-steps/

     

    - create time calendar: https://kohera.be/blog/power-bi/how-to-create-a-time-table-in-power-bi-in-a-few-simple-steps/

    slightly adapted:

    TimeTable =
    VAR HourTable = SELECTCOLUMNS(GENERATESERIES(0, 23), "Hour", [Value])
    VAR MinuteTable = SELECTCOLUMNS(GENERATESERIES(0, 59), "Minute", [Value])
    VAR SecondsTable = SELECTCOLUMNS(GENERATESERIES(0, 59), "Second", [Value])

    RETURN
    ADDCOLUMNS(
    CROSSJOIN(HourTable, MinuteTable, SecondsTable),
    "Time", TIME([Hour], [Minute], [Second]),
    "TimeRound", Time([Hour],[Minute],0),
    "TimeKwartuur",time([Hour],(if ([Minute]<15,0,if ([Minute]<30,15,if ([Minute]<45,30,45)))),0)
    )

    - link tables:

     

    - create table using Date and Kwartuur from the created tables:

    i'm still struggling with the fact that he is only showing me  the hours where there was input (so for example, nothing before 6:30), but i'm already a bit more on track

     

    thanks for the advice, it put me on the right track !

6 Replies