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

Count the Number of Systems selected by User

I have a data set that I need to perform a count of systems selected by a user (either 1, 2 or 3).  I then will take that result and do a count of the number of users that picked 1 system, 2 system or 3 systems.  Data is structured as follows:

 

UserSystemSystem Selected
User1Secondary Business SystemNo
User1Tertiary Business SystemNo
User1Primary Business SystemNo
User1Unlisted Business SystemsNo
User2Primary Business SystemYes
User2Secondary Business SystemNo
User2Tertiary Business SystemNo
User2Unlisted Business SystemsNo
User3Secondary Business SystemYes
User3Primary Business SystemYes
User3Unlisted Business SystemsNo
User3Tertiary Business SystemNo
User4Secondary Business SystemYes
User4Unlisted Business SystemsNo
User4Tertiary Business SystemNo
User4Primary Business SystemYes
user5Unlisted Business SystemsNo
user5Secondary Business SystemYes
user5Primary Business SystemYes
user5Tertiary Business SystemYes
user6Tertiary Business SystemNo
user6Primary Business SystemNo
user6Unlisted Business SystemsNo
user6Secondary Business SystemNo

 

And the resulting set by user should be

UserTotal Systems Selected
User10
User21
User32
User42
user53
user60

 

and then the final system count would look like

Total Systems Selected# Users
02
11
22
31

 

I know it's a count function, but I'm just not quite sure how to approach it in power bi.  

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

Try this measure, sustituting Table with your actual table name for your first table (with User column).

 

UserSelectedCount = Calculate(DistinctCount(Table[System]), Table[System Selected]="Yes")

 

For the second table, you'll need another table that has the 0,1,2,3.  You can generate a DAX table with

Counts = GENERATESERIES(0, 3, 1)

No relationship to any other table needed.

 

You can then make a table with the Counts[Values] column and this measure.

SystemCount = var selectedcount = Selectedvalue(Counts[Value])

return Countrows(Filter(Values(Table[User]), [UserSelectedCount] = selectedcount))

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Hi  @Anonymous ,

 

I test the method that @mahoneypat suggested. My sample works fine. You just used the wrong formula.

 

The second table:

Counts = GENERATESERIES(0, 3, 1)

2.PNG 

The measure:

SystemCount = 
var selectedcount = Selectedvalue(Counts[Value])
return 
Countrows(Filter(Values('Table'[User]), [UserSelectedCount] = selectedcount))

3.PNG

 

Best Regards,
Xue Ding
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
mahoneypat
Employee
Employee

Try this measure, sustituting Table with your actual table name for your first table (with User column).

 

UserSelectedCount = Calculate(DistinctCount(Table[System]), Table[System Selected]="Yes")

 

For the second table, you'll need another table that has the 0,1,2,3.  You can generate a DAX table with

Counts = GENERATESERIES(0, 3, 1)

No relationship to any other table needed.

 

You can then make a table with the Counts[Values] column and this measure.

SystemCount = var selectedcount = Selectedvalue(Counts[Value])

return Countrows(Filter(Values(Table[User]), [UserSelectedCount] = selectedcount))

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

I was able to create the measure and the count table but the second table is giving me an error.  I used the syntax:

 

SystemCount = var selectedcount = Selectedvalue(Counts[Value])

 

to create the DAX table, but it is saying the syntax for ')' is incorrect.  I may be misunderstanding that last step.  I feel like it's close I just need a little clarification on the last part.

 

Hi  @Anonymous ,

 

I test the method that @mahoneypat suggested. My sample works fine. You just used the wrong formula.

 

The second table:

Counts = GENERATESERIES(0, 3, 1)

2.PNG 

The measure:

SystemCount = 
var selectedcount = Selectedvalue(Counts[Value])
return 
Countrows(Filter(Values('Table'[User]), [UserSelectedCount] = selectedcount))

3.PNG

 

Best Regards,
Xue Ding
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.