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
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)

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
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.


Go to My LinkedIn Page


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)

Thanks @amitchandak 

works perfectly fine

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.