cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Anonymous
Not applicable

## Need to a quantity of an item between hours of the day

Sorry, english is not my first language.

I have a phone number dataset like so.

1 [from] [start time] [end time] [date]

I'm searching for a formula to create the following logic.

Call 1   [xxx] [10 AM] [10:15AM]

Call 2  [yyy] [10:10AM] [10:30AM]

Call 3   [bbb] [11:30 AM] [12:00AM}

Desired output

Time Frame             Count of sustained calls

[10:AM]                    1

[10:15AM]                2

[10:30 AM]               1

[10:45AM]

[11:00AM]

[11:15AM]

[11:30 AM]             1

[11:45AM]              1

[12:00AM]              1

I'm very new at this and would appriciate the help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Never mind, I found the solution. If I have the tables linked with an active relationship, you can use crossfilter like so:

CALCULATE(SUMX( Phone_LOGs , IF( [Result] = "Accepted" && Phone_LOGs[Time] <= MAX( 'Time'[Time of Day] ) && Phone_LOGs[End Time] >= MIN('Time'[Time of Day]) , 1 ,0)), CROSSFILTER('Time'[Time of Day] , Phone_LOGs[Time] , None))

I want to thank all the above participant for their insights & wish them all the best !

6 REPLIES 6
Super User

Probably this:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/td-p/409364

Maybe this:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Hour-Breakdown/m-p/625085#M306

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thank you for the reply.

Unfortunatly, I was not able to achive the desired results.

I attempted to run the following mesure:

Test sustained =

Var minTime = MIN('Time'[Time of Day])
Var maxTime = MAX('Time'[Time of Day])

var tempTable = FILTER(Phone_LOGs , Phone_LOGs[Time] <= maxTime &&
Phone_LOGs[End Time] >= minTime && Phone_LOGs[Result] = "Accepted")

return COUNTROWS(tempTable)

Unfortunaly, this brought me nowhere, as the above function only graphs the calls at created time, and does not aggregate them like the task requires.

Thank you in advance.

Community Support

Hi @Anonymous ,

I try creating a calculated table to implement your requirement. Maybe it can help you.

• Create a calculated table
``Table 2 = GENERATESERIES(TIME(0,0,0),TIME(23,59,59),TIME(0,15,0))``
•  Create calculated columns
``````Last Time =
CALCULATE (
MAX ( 'Table 2'[Value] ),
FILTER ( 'Table 2', 'Table 2'[Value] < EARLIER ( 'Table 2'[Value] ) )
)

Count number =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[Start date] <= 'Table 2'[Value]
&& 'Table'[End date] > 'Table 2'[Last time]
)
)
``````

If you want to use measures, you could try like this:

``````Measure =
CALCULATE (
COUNT ( 'Table'[Call] ),
FILTER (
'Table',
'Table'[Start date] <= MAX ( 'Table 2'[Value] )
&& 'Table'[End date] > MAX ( 'Table 2'[Last Time] )
)
)
``````

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi,

Your solution did not work well for my case, however it did allow me to distinguish the differences between your example and mine, thank you.

In short, I have an active relation between [Value] & [Start Date] that messes up with the mesure. Is there any way to keep that relation active, as it is used to graph other events in time other then the calls on the same graph.

Thank you in advance for your awsome work @!

Anonymous
Not applicable

Never mind, I found the solution. If I have the tables linked with an active relationship, you can use crossfilter like so:

CALCULATE(SUMX( Phone_LOGs , IF( [Result] = "Accepted" && Phone_LOGs[Time] <= MAX( 'Time'[Time of Day] ) && Phone_LOGs[End Time] >= MIN('Time'[Time of Day]) , 1 ,0)), CROSSFILTER('Time'[Time of Day] , Phone_LOGs[Time] , None))

I want to thank all the above participant for their insights & wish them all the best !

Anonymous
Not applicable

After a few hours of trying, I found this to work best with detached time tables:

SUMX( Phone_LOGs , IF( Phone_LOGs[Time] <= MAX( 'Time'[Time of Day] ) && Phone_LOGs[End Time] >= MIN('Time'[Time of Day]) , 1 ,0))

However, I have not found a way to deal with the relationship on active without duplicating the time table or adding use relationship to every mesure accessing that table.

Any idead anyone ?

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors