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
usomaraju
Helper II
Helper II

Based on distinct of id, get the earliest date from the next column

Hi,

 

Could someone help me on below issue.

i have the table with 3 columns

idenddateno of days
2003/13/20200
2003/13/20200
2023/19/202015
2023/19/202015
2023/27/202015
2075/1/20206
2075/6/20206

 

Out of which i need distinct of id with earliest of the date and corresponding days i need to store in a separate table or do filter on the same table.Is it possible to do? 

and the output for the above looks like below

idenddateno of days
2003/13/20200
2023/27/202015
2075/6/20206

 

 

 

 

8 REPLIES 8
Mariusz
Community Champion
Community Champion

Hi @usomaraju 

Try this.

Measure = 
SUMX(
    SUMMARIZE( 'Table', 'Table'[id], 'Table'[enddate] ),
    VAR __minDate = 
        CALCULATE(
            MIN( 'Table'[enddate] ), 
            ALLEXCEPT( 'Table', 'Table'[id] )  
        ) 
    RETURN 
        IF( 
            __minDate = 'Table'[enddate],
            CALCULATE( 
                MIN( 'Table'[no of days] ),
                'Table'[enddate] = __minDate 
            )
        )
)

for the below result 

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Hi Mariusz,

 

I tried your DAX formula, which returns only few records and also some of the id's of rows are missing

like for some of the rows below

 

idenddateno of days
1632/25/20202
1632/25/20202
1632/28/20202
1642/25/20201
1642/25/20201
1653/2/20206
1653/2/2026

 

when i apply measure, i get only one row as reslut for the id 164

idenddateno of daysMeasure
1642/25/202011

 

i'm not sure why its not populating the result for 163 and a65.

 

harshnathani
Community Champion
Community Champion

Hi @usomaraju ,

 

 

Create a measure

 

Max Date Id = CALCULATE(MAX('Table'[enddate]), ALLEXCEPT('Table','Table'[id]))
 
 
1.jpg
 

Don't Summarize when you pull number of Days.

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

Hi Harsh,

 

when i applied dax formula on my table, i see below result and every row it is calculating and i'm not sure about the valuse displaying in the measure column

 

for ex: for the id 163, i need the result as one row and the date should be 2/28/2020.

 
 

Capturedax .PNG

Hi @usomaraju ,

 

Try this measure

 

Max Date Id =

var a = MAXX(FILTER(ALL('Table'), 'Table'[ID] = Max('Table'[ID])), 'Table'[Date])

var b = If(MAx('Table'[Date]) = a,a ,Blank())

Return
b
 
1.jpg
Select Show items with no data
 
1.jpg
 
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

hi Harsh

 

Thank you so much for your quick response

 

i have used your dax, but in the result it starts from the id 173and not showing previous id's

i'm not sure why

 

before measure

Capturedax1.PNG

 

with measure

Capturedax2.PNG

hi harsh,

And also i checked with selected the show items with no data , it also displaying the data from id 173.

 

Capturedax3.PNG

Hi @usomaraju ,

 

Not sure why is this happening. It shows all values in my pbix.

 

Can you share sample of your pbix file for me to check.

 

Regards,

Harsh Nathani

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