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
Coffeeaddict
Frequent Visitor

Count of distinct values per day over a number of days

I am trying to create a measure to count the number of distinct values of a field per day over a number of days.  

 

Given a sample data set of 

Coffeeaddict_0-1601044717758.png

 

I am trying to create a measure that when looking at the 3 days will return a value of 5 based on customer (2+1+2)

 

I cannot use any calculations which will not work with RLS.

 

 

1 ACCEPTED SOLUTION

Due to the description of SUMX i dont think it can be used with row level security which will be added to the dataset later so the suggestion cannot be used.

 

This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

 

I solved this be creating a merged colum of customer id and date to create a field i could do a distinct count on.

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi  @Coffeeaddict ,

 

Is your issue solved?Did @HotChilli 's suggestion help?

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Due to the description of SUMX i dont think it can be used with row level security which will be added to the dataset later so the suggestion cannot be used.

 

This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

 

I solved this be creating a merged colum of customer id and date to create a field i could do a distinct count on.

Hi @Coffeeaddict ,

 

Great! Could you pls mark the reply as answered to close it?

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table and build a relationship from the day column of your data table to the date column of your calendar table.  Create a date slicer from your Calendar table and select any date range.  Try this measure

=sumx(summarize(values(calendar[date]),calendar[date],"ABCD",distinctcount(data[customer])),[abcd])

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
HotChilli
Super User
Super User

Looks like a good case for a nested measure:

CDistinct = DISTINCTCOUNT(TableJJ[Customer])

 

Use the above like this:

MeasureQQ = SUMX(DISTINCT(TableJJ[day]),  [CDistinct]  )

 

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.