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

Sum of Effort between 2 dates based on first instance of a condition

Example Table 

Looking for suggestions on how to approach this the best way.  I need to be able to show total of Worked, summarized by consumer number, using the Placement date as the start date, and the Date of the first instance of Action code "pmtschsm".

 

danimal23_0-1624387874270.png

 

 In the attached sample table example, we would expect the totals for each consumer to be:

consumer 6297225 - 19

consumer 6295290 - 14

 

Any advice on how to approach or solve this problem would be greatly appreciated.  Thanks all

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Anonymous,

 

Try this measure:

 

Total Worked = 
VAR vPlacementDate =
    CALCULATE (
        MAX ( Table1[Placement] ),
        ALLEXCEPT ( Table1, Table1[ConsumerNumber] )
    )
VAR vMinDatePmt =
    CALCULATE (
        MIN ( Table1[Date] ),
        ALLEXCEPT ( Table1, Table1[ConsumerNumber] ),
        Table1[ActionCode] = "PMTSCHSM"
    )
VAR vResult =
    CALCULATE (
        SUM ( Table1[Worked] ),
        ALLEXCEPT ( Table1, Table1[ConsumerNumber] ),
        Table1[Date] >= vPlacementDate,
        Table1[Date] <= vMinDatePmt
    )
RETURN
    vResult




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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Access Denied message when i try to download the file.  For 6297225 why should the answer be 19?  What do you mean by Date of the first instance of Action code "pmtschsm"?  In the MS Excel file that you upload, please show the expected result with simple Excel formulas so that your logic can be understood


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur sorry Ashish, not sure why the link is blocked.  I will check on it.  But it's ok @DataInsights have solved the problem.  Thank you so much for responding!

DataInsights
Super User
Super User

@Anonymous,

 

Try this measure:

 

Total Worked = 
VAR vPlacementDate =
    CALCULATE (
        MAX ( Table1[Placement] ),
        ALLEXCEPT ( Table1, Table1[ConsumerNumber] )
    )
VAR vMinDatePmt =
    CALCULATE (
        MIN ( Table1[Date] ),
        ALLEXCEPT ( Table1, Table1[ConsumerNumber] ),
        Table1[ActionCode] = "PMTSCHSM"
    )
VAR vResult =
    CALCULATE (
        SUM ( Table1[Worked] ),
        ALLEXCEPT ( Table1, Table1[ConsumerNumber] ),
        Table1[Date] >= vPlacementDate,
        Table1[Date] <= vMinDatePmt
    )
RETURN
    vResult




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

Proud to be a Super User!




Anonymous
Not applicable

@DataInsights This worked PERFECTLY!  Amazing job.  Thank you so much for responding!

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.