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
jguercio
Frequent Visitor

Overlapping Time Problem

Hi All,

 

I will start with the obligatory, I am new to this and crawling up the learning curve.
I am having an issue handling overlapping time and need a way of appropriately dealing with the durations (either summing them, using a max, etc.). Basically, when an employee (or more than one employee) writes a note for the same client on the same day, if the times overlap, a rule needs to be put in place to handle aggregating them. The chart below illustrates the issue and what durations we need to use for billing. As an example, in the first condition, with the same start times (SE) and different end times (DE) we use the row with the MAX duration (yellow). 

 

DD Billing.jpg.png

I have a FACT table set up like this:
FACT-DD Services:

ClientID

Contact Date

Start Time

End Time

Duration (Minutes)

(etc)

 

That I have summarized this table by day for other purposes using this:

 

DD Billing PS = CALCULATETABLE(
                        SUMMARIZE(
                            'FACT-DD Services'
                            ,'FACT-DD Services'[Client ID]
                            ,'FACT-DD Services'[First Name]
                            ,'FACT-DD Services'[Last Name]
                            ,'FACT-DD Services'[Contact Date]
                            ,'FACT-DD Services'[Start Time]
                            ,'FACT-DD Services'[End Time]
                            ,'FACT-DD Services'[Created By]
                            ,"Contact Note"
                                ,CALCULATE(
                                    SUMX('FACT-DD Services'
                                    ,'FACT-DD Services'[Duration (Minutes)])
                                    ,'FACT-DD Services'[Note Type]="Contact Note"
                                    )
                            ,"Service Linked Note"
                                ,CALCULATE(
                                    SUMX('FACT-DD Services'
                                    ,'FACT-DD Services'[Duration (Minutes)])
                                    ,'FACT-DD Services'[Note Type]="Service/Treatment Plan Linked"
                                )

 And used this on the summarized table to identify overlaps:

Overlaping Documentation = 
VAR Overlapped=
              COUNTROWS(
                      FILTER(
                               ALL('DD Billing PS'),
                               'DD Billing PS'[Start Time] <= EARLIER('DD Billing PS'[Start Time]) &&
                               'DD Billing PS'[End Time] >= EARLIER('DD Billing PS'[End Time]) &&
                               'DD Billing PS'[Contact Date] = EARLIER('DD Billing PS'[Contact Date]) &&
                               'DD Billing PS'[Start Time] <> Earlier('DD Billing PS'[End Time]) &&
                               'DD Billing PS'[Client ID] = EARLIER('DD Billing PS'[Client ID])
                               )
                    )
RETURN
IF(Overlapped>1, "YES", "NO")

 Any help or support is greatly appreciated!

1 REPLY 1
Stachu
Community Champion
Community Champion

Can you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data? Like this (just copy and paste into the post window).

Column1Column2
A1
B2.5

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

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.

Top Solution Authors