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

DISTINCT COUNT Grouped in BINs Filtered Dynamically

Good morning!

Could I ask if any one of you can solve this model:

 

I have read a number of post before and asked help from which I learned how to:
- Do bins in a graph with a bins table

- DISTINCTCOUNT() my users to get the number of entries per day / period using a measure 

 

The Challange:

- Filter both the User & Login tables dynamically (with a slicer) so that I can show the aggregated logins of users that were active during the specified time. That is, users that were Licensed but had zero logins should appear in the graph under the "0 logins" bin. Just showing users that > 0 logins in period does not cut it.  

 

It is possible to build a measure on the DISTINCTCOUNT() measure (which specifies the number of logins in the given period per user) which groups the counts of users, that are "Licensed", during the given period? 

 

POwerBIModel.png

 

Thank you inadvance!

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

Hello @ThomasBart

First create a column in the table "User login registration"

date = [login datetime]. [Date]

Create a relationship between this table and the "date" table based on this new "date" column created.

Next, create a measure in the table "User Login Registration"

count of record = CALCULATE(DISTINCTCOUNT('Usre login record'[date]),FILTER(ALLSELECTED('system users'),'system users'[Unique Id]=MAX('system users'[Unique Id])))

Next, create a range table as the links you provide.

Create a measure

count range =
CALCULATE (
    DISTINCTCOUNT ( 'system users'[Unique Id] ),
    FILTER (
        VALUES ( 'system users' ),
        COUNTROWS (
            FILTER (
                'range table',
                'range table'[min] <= [count of record]
                    && 'range table'[max] >= [count of record]
            )
        ) > 0
            && 'system users'[user status] = "Licensed"
    )
)

Add "range" and this measurement to the column chart.

Capture1.JPG

Best regards
Maggie
Community Support Team _ Maggie Li
If this post helps, please consider accepting it as the solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hello @ThomasBart

First create a column in the table "User login registration"

date = [login datetime]. [Date]

Create a relationship between this table and the "date" table based on this new "date" column created.

Next, create a measure in the table "User Login Registration"

count of record = CALCULATE(DISTINCTCOUNT('Usre login record'[date]),FILTER(ALLSELECTED('system users'),'system users'[Unique Id]=MAX('system users'[Unique Id])))

Next, create a range table as the links you provide.

Create a measure

count range =
CALCULATE (
    DISTINCTCOUNT ( 'system users'[Unique Id] ),
    FILTER (
        VALUES ( 'system users' ),
        COUNTROWS (
            FILTER (
                'range table',
                'range table'[min] <= [count of record]
                    && 'range table'[max] >= [count of record]
            )
        ) > 0
            && 'system users'[user status] = "Licensed"
    )
)

Add "range" and this measurement to the column chart.

Capture1.JPG

Best regards
Maggie
Community Support Team _ Maggie Li
If this post helps, please consider accepting it as the solution to help other members find it more quickly.

Anonymous
Not applicable

Hello Maggie,

 

This is a really sick piece of help, thank you so much the key was the "..FILTER(ALLSELECTED(..." part of the formula.

 

I am veyr greatfull!

 

Thomas

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.