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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Measure for counting unique users grouped by a parameter

Hi there!
Consider a table of facts. Each record contains user_id and some flag (true/false). I need to count unique users according to that flag and visualize it like a bar. For instance imagine that there're 10 users (10 records) with flag = "false" - (0, 10). After appending 2 records (12 records in total) where flag = "true" we get (2, 8), but not (2, 10). I came up with this measure which is as straight as possible, but gives no grouping at all.

 

unique_users = 
    VAR users_true = CALCULATETABLE(
        DISTINCT(users[user_id]),
        users[flag] = "true"
    )
    VAR users_false = CALCULATETABLE(
        DISTINCT(users[user_id])
    )

    RETURN SWITCH(
        TRUE(),
        "true" IN flags, COUNTROWS(users_true),
        COUNTROWS(users_false) - COUNTROWS(users_true)
    )

 

 

 img.png

 

 

 

Thank you beforehand and best regards!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Try it.

unique_users = 
VAR users_true =
    SUMMARIZE(FILTER('users', users[flag] = "true" ),[user_id])
VAR users_false =
    SUMMARIZE('users',[user_id])
RETURN
 COUNTROWS ( users_false ) - COUNTROWS ( users_true )

The final output is shown below:

vyalanwumsft_0-1637808342890.png

Sorry I can't reproduce your data model, if this formula does not apply to your model, can you share simple files or scenarios?


Best Regards,
Community Support Team_ Yalan Wu
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

1 REPLY 1
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Try it.

unique_users = 
VAR users_true =
    SUMMARIZE(FILTER('users', users[flag] = "true" ),[user_id])
VAR users_false =
    SUMMARIZE('users',[user_id])
RETURN
 COUNTROWS ( users_false ) - COUNTROWS ( users_true )

The final output is shown below:

vyalanwumsft_0-1637808342890.png

Sorry I can't reproduce your data model, if this formula does not apply to your model, can you share simple files or scenarios?


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors