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
Anonymous
Not applicable

Measure that counts unique IDs in a group modified by a filter.

I'm trying to create a measure that sums up the number of unique ids (Session IDs) over a group (Account ID) only where date 1 is less than date 2. 

 

I have managed to only execute for the correct rows but my calculation sums up all rows per Account ID.  

karlal_0-1605100420744.png

 

Any suggestions? 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

You can follow the below steps to get it:

1. Create a calculated column to get the flag using compare date 1 and date 2

 

Flag = IF('data'[date1]<'data'[date2],1,0)​

 

2. Create a measure to get the count of sessions

 

Measure = 
VAR _tab=SUMMARIZE(FILTER(ALLEXCEPT('data','data'[Account Id]),'data'[Flag]=1),"countofSession",CALCULATE(DISTINCTCOUNT('data'[Session ID])))
RETURN IF(MAX('data'[Flag])=1,SUMX(_tab,[countofSession]))

 

Measure that counts unique IDs in a group modified by a filter..JPGBest Regards

Community Support Team _ Rena
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
amitchandak
Super User
Super User

@Anonymous , Try a measure like

sumx(values(data[Account ID]), calculate(Distinctcount(data[SessionID])))

Anonymous
Not applicable

Thank you @amitchandak however I got the following table following your advice. 

karlal_0-1605102712263.png

 

Hi @Anonymous ,

You can follow the below steps to get it:

1. Create a calculated column to get the flag using compare date 1 and date 2

 

Flag = IF('data'[date1]<'data'[date2],1,0)​

 

2. Create a measure to get the count of sessions

 

Measure = 
VAR _tab=SUMMARIZE(FILTER(ALLEXCEPT('data','data'[Account Id]),'data'[Flag]=1),"countofSession",CALCULATE(DISTINCTCOUNT('data'[Session ID])))
RETURN IF(MAX('data'[Flag])=1,SUMX(_tab,[countofSession]))

 

Measure that counts unique IDs in a group modified by a filter..JPGBest Regards

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

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.