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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

First and last dates and values

Greetings,

 

I need to help to identify the first and last date and values in a table.  Min and Max won't work because the values are a combination of increasing and decreasing amounts.

 

Here is a sample of the table:

CUSTOMER CODEDATEDISCOUNT
A0511/1/20220.2
A0516/1/20220.1
A25112/1/20210.2
B10012/1/20210.05
B1006/1/20220.1
B10111/1/20210.03
B1019/1/20220.08
B10612/1/20210.25
B1065/1/20220.3
B11110/1/20210.1
B1113/1/20220.05
C2133/1/20220.15
C51612/1/20210.25
C5165/1/20220.15

 

Here is the result I looking for:

CUSTOMER CODELAST DATEFIRST DISCOUNTLAST DISCOUNT
A0516/1/20220.20.1
A25112/1/20210.20.2
B1006/1/20220.050.1
B1019/1/20220.030.08
B1065/1/20220.250.3
B1113/1/20220.10.05
C2133/1/20220.150.15
C5165/1/20220.250.15

 

Note: Some of the customers have only one entry, therefore, the first/last discount will be the same value.

 

Thank you in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try measures as below to create a table visual.

First Discount =
VAR _STARTDATE =
    CALCULATE (
        MIN ( 'Table'[DATE] ),
        ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[DISCOUNT] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] ),
            'Table'[DATE] = _STARTDATE
        )
    )
Last Discount =
VAR _EndDATE =
    CALCULATE (
        MAX ( 'Table'[DATE] ),
        ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[DISCOUNT] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] ),
            'Table'[DATE] = _EndDATE
        )
    )

Result is as below.

RicoZhou_0-1661329645047.png

 

Best Regards,
Rico Zhou

 

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try measures as below to create a table visual.

First Discount =
VAR _STARTDATE =
    CALCULATE (
        MIN ( 'Table'[DATE] ),
        ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[DISCOUNT] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] ),
            'Table'[DATE] = _STARTDATE
        )
    )
Last Discount =
VAR _EndDATE =
    CALCULATE (
        MAX ( 'Table'[DATE] ),
        ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[DISCOUNT] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[CUSTOMER CODE] ),
            'Table'[DATE] = _EndDATE
        )
    )

Result is as below.

RicoZhou_0-1661329645047.png

 

Best Regards,
Rico Zhou

 

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

ddpl
Solution Sage
Solution Sage

@Anonymous 

Hey, Create a new calculated table as per below...

 

Your Need = 
SUMMARIZE(
'Table','Table'[CUSTOMER CODE],
"Last Date", MAX('Table'[DATE]),
"1st Disc", CALCULATE(MAX('Table'[DISCOUNT]),'Table'[DATE]=MIN('Table'[DATE])),
"Last Disc", CALCULATE(MAX('Table'[DISCOUNT]),'Table'[DATE]=MAX('Table'[DATE])))

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors