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

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

Reply
Pbiuserr
Post Prodigy
Post Prodigy

How to calculate repeated ID and dates only once?

Hello,

My dataset looks like that. I'd need to calculate count of ID with earliest date excatly once and only for each ID.Status needs to be "B"

 

Pbiuserr_0-1657626833350.png

 

1 ACCEPTED SOLUTION

Ok, I've tested this out. Since you have several rows with the same ID, CrashDate and Status, unless you add an index to differentiate these rows (or there's another field which renders each row unique), PBI will summarize these rows into a single row.

 

1) So, to keep your structure and show all the rows, I have added an index column to render each row unique. As I say, if there is a field in the data which makes each row unique, you can use that field instead of the Index field I've used in the measure.

I have worked on this sample dataset (including the Index column)
set.pngThe measure:

 

Min date per ID single row =
VAR _MinDateID =
    CALCULATE (
        MIN ( FTable[CrashDate] ),
        FILTER ( ALLEXCEPT ( FTable, FTable[ID] ), FTable[Status] = "B" )
    )
VAR _SelID =
    MAX ( FTable[ID] )
VAR _MinRow =
    CALCULATE (
        MIN ( FTable[Index] ),
        FILTER ( ALL ( FTable ), FTable[CrashDate] = _MinDateID && FTable[ID] = _SelID )
    ) // IF you have a field which renders each row unique, use the field (you don't then need the index column)
VAR _Summary =
    SUMMARIZE (
        FILTER ( FTable, FTable[Index] = _MinRow && FTable[CrashDate] = _MinDateID ),
        FTable[ID],
        FTable[CrashDate]
    ) // Again, if you have the unique field, use it instead of the FTable[Index] field
RETURN
    IF ( COUNTROWS ( _Summary ) = 1, _MinDateID )

 

Which gets you this:

resukt 1.png2) If you don't need to show all the rows, and the summary suffices (you don't need the index column), you can use this measure:

 

Min date by Id for "B" Status =
VAR _MinDateID =
    CALCULATE (
        MIN ( 'FTable'[CrashDate] ),
        FILTER ( ALLEXCEPT ( 'FTable', 'FTable'[ID] ), 'FTable'[Status] = "B" )
    )
VAR _Summary =
    SUMMARIZE (
        FILTER ( FTable, FTable[CrashDate] = _MinDateID ),
        FTable[CrashDate],
        [ID]
    )
RETURN
    IF ( COUNTROWS ( _Summary ) = 1, _MinDateID )

 

To get:

Res2.pngI've attached the sample PBIS file

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
v-easonf-msft
Community Support
Community Support

Hi, @Pbiuserr 

Please try formula like:

Count =
CALCULATE (
    DISTINCTCOUNT ( Table[ID] ),
    FILTER ( ALLEXCEPT ( Table, Table[Date].[Month] ), Table[Status] = "B" )
)

If it doesn't work, please explain further your expected results

 

Best Regards,
Community Support Team _ Eason

PaulDBrown
Community Champion
Community Champion

If you need the earliest date by IP and Status, try:

Min date = CALCULATE (MIN(Table[Date]), ALLEXCEPT(Table, Table[IP], Table[Status]))





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

Try:

Min date = CALCULATE (MIN(Table[Date]), FILTER(ALLEXCEPT(Table, Table[IP]), Table [Status] = "B"))





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi,

It gives me only earliest date from entire dataset. I'd like to count earliest date per ID with that status. Could you help me?

Ok, I've tested this out. Since you have several rows with the same ID, CrashDate and Status, unless you add an index to differentiate these rows (or there's another field which renders each row unique), PBI will summarize these rows into a single row.

 

1) So, to keep your structure and show all the rows, I have added an index column to render each row unique. As I say, if there is a field in the data which makes each row unique, you can use that field instead of the Index field I've used in the measure.

I have worked on this sample dataset (including the Index column)
set.pngThe measure:

 

Min date per ID single row =
VAR _MinDateID =
    CALCULATE (
        MIN ( FTable[CrashDate] ),
        FILTER ( ALLEXCEPT ( FTable, FTable[ID] ), FTable[Status] = "B" )
    )
VAR _SelID =
    MAX ( FTable[ID] )
VAR _MinRow =
    CALCULATE (
        MIN ( FTable[Index] ),
        FILTER ( ALL ( FTable ), FTable[CrashDate] = _MinDateID && FTable[ID] = _SelID )
    ) // IF you have a field which renders each row unique, use the field (you don't then need the index column)
VAR _Summary =
    SUMMARIZE (
        FILTER ( FTable, FTable[Index] = _MinRow && FTable[CrashDate] = _MinDateID ),
        FTable[ID],
        FTable[CrashDate]
    ) // Again, if you have the unique field, use it instead of the FTable[Index] field
RETURN
    IF ( COUNTROWS ( _Summary ) = 1, _MinDateID )

 

Which gets you this:

resukt 1.png2) If you don't need to show all the rows, and the summary suffices (you don't need the index column), you can use this measure:

 

Min date by Id for "B" Status =
VAR _MinDateID =
    CALCULATE (
        MIN ( 'FTable'[CrashDate] ),
        FILTER ( ALLEXCEPT ( 'FTable', 'FTable'[ID] ), 'FTable'[Status] = "B" )
    )
VAR _Summary =
    SUMMARIZE (
        FILTER ( FTable, FTable[CrashDate] = _MinDateID ),
        FTable[CrashDate],
        [ID]
    )
RETURN
    IF ( COUNTROWS ( _Summary ) = 1, _MinDateID )

 

To get:

Res2.pngI've attached the sample PBIS file

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks! Very insightful and helpful. Turned out that your first measure along with MIN on dates is fine, but I guess you achieved the same result. Thank you very much!

Helpful resources

Announcements
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 Kudoed Authors