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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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