Reply
Frequent Visitor
Posts: 5
Registered: ‎12-21-2017
Accepted Solution

Time Buckets in Power BI

Hi everyone

I have created a new table with "Enter Data" option. I want to use this table for bucketing. Please see the following two tables.

I want to calculate "Total Accidents" by Timeinterval. for example

how many accidents occured in between 07:00 - 12:00 19:00-06:00 and 13:00-18:00

and want to show in a column bar chart.

table.JPG


Accepted Solutions
Community Support Team
Posts: 1,997
Registered: ‎07-10-2018

Re: Time Buckets in Power BI

Hi @skiper,

 

To create a mreasure as below.

 

Measure = 
VAR mas =
    MAX ( Timeinterval[Starttime] )
VAR mae =
    MAX ( Timeinterval[Endtime] )
RETURN
    IF (
        mas < mae,
        CALCULATE (
            SUM ( trafficAccident[Total Accidents] ),
            FILTER (
                ALL ( trafficAccident ),
                trafficAccident[Accident time] >= mas
                    && trafficAccident[Accident time] <= mae
            )
        ),
        IF (
            mas > mae,
            CALCULATE (
                SUM ( trafficAccident[Total Accidents] ),
                FILTER (
                    ALL ( trafficAccident ),
                    trafficAccident[Accident time] >= mas
                        || trafficAccident[Accident time] <= mae
                )
            )
        )
    )

Capture.PNG

For more details ,please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Attachment

All Replies
Super User
Posts: 10,605
Registered: ‎07-11-2015

Re: Time Buckets in Power BI


Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


Community Support Team
Posts: 1,997
Registered: ‎07-10-2018

Re: Time Buckets in Power BI

Hi @skiper,

 

To create a mreasure as below.

 

Measure = 
VAR mas =
    MAX ( Timeinterval[Starttime] )
VAR mae =
    MAX ( Timeinterval[Endtime] )
RETURN
    IF (
        mas < mae,
        CALCULATE (
            SUM ( trafficAccident[Total Accidents] ),
            FILTER (
                ALL ( trafficAccident ),
                trafficAccident[Accident time] >= mas
                    && trafficAccident[Accident time] <= mae
            )
        ),
        IF (
            mas > mae,
            CALCULATE (
                SUM ( trafficAccident[Total Accidents] ),
                FILTER (
                    ALL ( trafficAccident ),
                    trafficAccident[Accident time] >= mas
                        || trafficAccident[Accident time] <= mae
                )
            )
        )
    )

Capture.PNG

For more details ,please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Attachment
Community Support Team
Posts: 1,997
Registered: ‎07-10-2018

Re: Time Buckets in Power BI

Hi @skiper,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.


Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor
Posts: 5
Registered: ‎12-21-2017

Re: Time Buckets in Power BI

Hi Frank

THankyou very much for your help. 

I really appreciate that

Regards

Asim/skiper