Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

putting time intervals into bins

Hi Everyone

I have been struggling with a task for quite a while now without getting anywhere. I hope You can help me. 

I have unixtime and datetime to work with.

 

I have a table of customers that use my app. I want to know how many are active in 1 minutes interval of the day (or maybe 5/10/15)

Eg: 

 

Customer nostarttimeendtime
223

2017-07-06 00:01:41.0000000

2017-07-06 00:02:41.0000000
2212017-07-06 01:33:41.00000002017-07-06 01:39:41.0000000
2202017-07-06 01:10:41.00000002017-07-06 01:32:41.0000000
2252017-07-06 05:32:41.00000002017-07-06 09:32:41.0000000
2262017-07-06 06:32:41.00000002017-07-06 07:32:41.0000000
2242017-07-06 06:32:41.00000002017-07-06 06:50:41.0000000

 

I would like to make a graph that has a bin per minute on a given date on the x-axis and then count no. of active users in that minute on the y-axis. This would enable me to see that in the interval 2017-07-06 00:00 to 2017-07-06 00:01 there were X active customers. 
So if a customer has used the app in two minutes, he must be counted in two buckets. Note that a given customer can appear multiple times on a given day.


Best Regards and thanks in advance, Emilie

 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

For your case, you could try this way as below:

Step1:

You must define a bin date time dim table, you could refer to this formula:

DateTime bins Table = 
SELECTCOLUMNS( 
    GENERATE (
        CALENDAR ( MIN ( data[starttime] ), MAX ( data[endtime] ) ),
        GENERATESERIES (
            TIME ( 00, 0, 0 ),  --From
            TIME ( 23, 59, 0 ), --To
            TIME ( 0, 1, 0 )    --Every 1 mins
        )
    ),
    "Datetime", [Date]+[Value],"Date",[Date],"Time",[Value]
)

Step2:

Use this formula get the result measure

Measure = 
CALCULATE (
    COUNTA ( data[Customer no] ),
    FILTER (
        data,
        data[starttime] <= SELECTEDVALUE ( 'DateTime bins Table'[Datetime] )
            && SELECTEDVALUE ( 'DateTime bins Table'[Datetime] ) <= data[endtime]
    )
)

 

Here is sample pbix file, please try it.

 

and here is a similar post, you could refer to it.

 

Regards,

Lin

Community Support Team _ Lin
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

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

For your case, you could try this way as below:

Step1:

You must define a bin date time dim table, you could refer to this formula:

DateTime bins Table = 
SELECTCOLUMNS( 
    GENERATE (
        CALENDAR ( MIN ( data[starttime] ), MAX ( data[endtime] ) ),
        GENERATESERIES (
            TIME ( 00, 0, 0 ),  --From
            TIME ( 23, 59, 0 ), --To
            TIME ( 0, 1, 0 )    --Every 1 mins
        )
    ),
    "Datetime", [Date]+[Value],"Date",[Date],"Time",[Value]
)

Step2:

Use this formula get the result measure

Measure = 
CALCULATE (
    COUNTA ( data[Customer no] ),
    FILTER (
        data,
        data[starttime] <= SELECTEDVALUE ( 'DateTime bins Table'[Datetime] )
            && SELECTEDVALUE ( 'DateTime bins Table'[Datetime] ) <= data[endtime]
    )
)

 

Here is sample pbix file, please try it.

 

and here is a similar post, you could refer to it.

 

Regards,

Lin

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

Thanks a million! This was exactly what I needed!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.