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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
brettg
Helper II
Helper II

Count number of tests

Hello,

 

I would like to make a table which shows me users with 1 test, 2 tests, 3 tests etc. Something like the below based on the data set.

 

I know I could do this using "group by", but then I wouldn't be able to look at historic data. Is there a way to do this with a measure that would consider the date slicers on the page? (If I change date slicers, only tests in that period are counted)

 

Test CountNumber of users
11
22
31

 

UserIDGenderAgeTestResultTestDateTime
006Male34PASS2022-02-01 19:50:10.897
001Female29PASS2022-01-31 18:35:25.830
004Male25FAIL2022-01-30 10:50:48.873
001Female29PASS2022-01-28 11:39:51.737
001Female29FAIL2022-01-27 11:49:38.180
002Female36PASS2022-01-26 15:07:48.967
004Male25PASS2022-01-25 14:56:13.130
006Male34PASS2022-01-24 17:41:15.973
1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @brettg ,

 

Firstly, create a table for "Count":

New Table = {1,2,3}

Eyelyn9_0-1644458199771.png

 

Please try:

Count = 
CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),[UserID]=MAX('Table'[UserID]) &&  [TestDateTime]>=MIN('Table'[TestDateTime]) && [TestDateTime]<=MAX('Table'[TestDateTime])))
Count(again based on meassure) = 
var _t=SUMMARIZE('Table','Table'[UserID],"Count by UserID",[Count])
return COUNTROWS(FILTER(_t,[Count by UserID]=MAX('New Table'[Test])))+0

Output:

count based on measure.gif

 

 

Best Regards,
Eyelyn Qin
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

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @brettg ,

 

Firstly, create a table for "Count":

New Table = {1,2,3}

Eyelyn9_0-1644458199771.png

 

Please try:

Count = 
CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),[UserID]=MAX('Table'[UserID]) &&  [TestDateTime]>=MIN('Table'[TestDateTime]) && [TestDateTime]<=MAX('Table'[TestDateTime])))
Count(again based on meassure) = 
var _t=SUMMARIZE('Table','Table'[UserID],"Count by UserID",[Count])
return COUNTROWS(FILTER(_t,[Count by UserID]=MAX('New Table'[Test])))+0

Output:

count based on measure.gif

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Eyelyn,

 

This is perfect thank you! Just what I was looking for.

 

Where you've done {1,2,3} on the new table, would it be simple for me to go up to 10 and then include "10 or more"? 

 

Kind regards,

Brett

brettg
Helper II
Helper II

Not quite what I'm looking for I'm afraid! SelectedValue won't work when my date slicer is between two values.

 

I think I need two measures? one to count the distinct UserID's and another to group them

brettg
Helper II
Helper II

Hello,

 

I need the measure to do a distinct count for "UserID" from the second table. 

 

Then I'd like to create the first table by grouping the user counts into repeat test usage.

Measure = CALCULATE(distinctCount(Table[UserId]),selectedvalue( Table[date]))


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



mh2587
Super User
Super User

Measure = CALCULATE(Count(Table[Test]),selectedvalue( Table[date]))

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.