cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
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 !

 

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
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!:
Mastering Power BI 2nd Edition

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.
 
 

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] )
    )
)

 4.PNG

For more details, please download the attachment.

 

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 ?

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors