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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
saanah2019
Helper II
Helper II

Return both the Max and Min value for a date

 


So I have 3 columns in 1 table. The table is Billing and the three columns are Id, Date, Insurance Name.

 

IdDateInsurance Name
1008/15/2018Aetna
1008/16/2018Aetna
1018/18/2018Fidelis
1028/25/2018Fidelis
1028/15/2018Healthfirst
1027/15/2018Healthfirst
1028/10/2018Healthfirst
1038/6/2018Aetna
1038/9/2018Aetna
1038/15/2018Healthfirst
1048/24/2018Fidelis
1048/30/2018Fidelis

 

 

I want to only include the values for the max date and min date. I have alot of values for a specific Id, some have like 6 seven fields and I want to do some basic calculations and so only need two date values, the max and min. For examply the original table will now show only these rows:

IdDateInsurance Namemax or min
1008/15/2018Aetnamin
1008/16/2018Aetnamax
1018/18/2018Fidelismax
1028/25/2018Fidelismax
    
1027/15/2018Healthfirstmin
    
1038/6/2018Aetnamin
    
1038/15/2018Healthfirstmax
1048/24/2018Fidelismin
1048/30/2018Fidelismax
1 ACCEPTED SOLUTION

Hi @saanah2019 

You may create a measure like below:

Measure =
VAR min_date =
    CALCULATE ( MIN ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[Id] ) )
VAR max_date =
    CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[Id] ) )
RETURN
    IF (
        MAX ( Table1[Date] ) = max_date,
        "max",
        IF ( MAX ( Table1[Date] ) = min_date, "min" )
    )

1.png

Regards,

Community Support Team _ Cherie Chen
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

3 REPLIES 3
Anonymous
Not applicable

What determines if you want to see the min or the max?

@Anonymous I want to basically filter on the date, so basically create a new column which willl only show me the min and max dates

Hi @saanah2019 

You may create a measure like below:

Measure =
VAR min_date =
    CALCULATE ( MIN ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[Id] ) )
VAR max_date =
    CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[Id] ) )
RETURN
    IF (
        MAX ( Table1[Date] ) = max_date,
        "max",
        IF ( MAX ( Table1[Date] ) = min_date, "min" )
    )

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.