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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ubaid
Frequent Visitor

Count of first ID

I have two columns one is of ID and other is of Date, ID is repeating on different dates but I want to calculate the first count of ID,

let supose ID "111" is created on 1-08-2022, then on 2-08-2022, 3-08-2022, and 5-08-2022, but I want to show the count of ID "111" on 1-08-2022 rest of the dates count should be blank for the ID "111"

 

Ubaid_0-1662122883075.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Ubaid . Create a flag and use that in filter

a new column

flag = if([Date] = minx(filter(Table, [ID] =earlier([ID]) ), [Date]) , 1, 0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Ubaid,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1662126588721.png

 

 

Count of ID measure: =
VAR _currentdate =
    MAX ( Data[Date] )
VAR _currentidlist =
    VALUES ( Data[ID] )
VAR _currentidlistbeforecurrent =
    SUMMARIZE (
        FILTER ( ALL ( Data ), Data[ID] IN _currentidlist && Data[Date] < _currentdate ),
        Data[ID]
    )
VAR _currentidcount =
    COUNTROWS ( _currentidlist )
VAR _beforecurrentidcount =
    COUNTROWS ( _currentidlistbeforecurrent )
RETURN
    IF ( HASONEVALUE ( Data[Date] ), _currentidcount - _beforecurrentidcount )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@Ubaid . Create a flag and use that in filter

a new column

flag = if([Date] = minx(filter(Table, [ID] =earlier([ID]) ), [Date]) , 1, 0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak 

works perfectly fine

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.