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

Pie chart grouping customers by number of appearences in database and time filtering

Hello,

 

I have the following example of my database (see table below) where I want to count the number of times a customer was validated, then group it by clusters (ex.: less than 5 times, between 5 and 10, more than 10). 

 

Client IDStatusDatetime
AValidated10/09/2018
ACancelled11/09/2018
AValidated12/09/2018
BValidated10/09/2018
BValidated11/09/2018
BValidated12/09/2018
BValidated13/09/2018
BValidated14/09/2018
BValidated15/09/2018
CCancelled19/09/2018
CValidated20/09/2018
CCancelled21/09/2018
CCancelled22/09/2018

 

At the moment, I can do a table with the clients and number of bookings validated, filtered by date, like that:

 

ClientFrequency
A2
B6
C1

 

 

But what I want is to show it in a pie chart with how many customers are in each cluster and the possibility to filter by date.

So at the end I want to have this pie chart with the % or number of customers that are in each category for the month of September for example :

Pie chart

Please could someone help me with that?

 

Thanks a lot,

 

Lucas

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

HI @Anonymous,

 

I'd like to suggest you add calculated column to group your records with frequency label, then write a measure to calculate validated records count.

 

Calculate column:

Clusters = 
VAR frequency =
    COUNTROWS (
        FILTER (
            ALL ( Table1 ),
            [Client ID] = EARLIER ( Table1[Client ID] )
                && [Status] = "Validated"
                && FORMAT ( [Datetime], "mm/yyyy" )
                    = FORMAT ( EARLIER ( Table1[Datetime] ), "mm/yyyy" )
        )
    )
RETURN
    IF (
        frequency > 10,
        "More than 10",
        IF (
            frequency > 5 && frequency < 10,
            "between 5 to 10",
            IF ( frequency < 5, "less than 5" )
        )
    )

Measure:

Validated count = 
CALCULATE (
    COUNT ( Table1[Datetime] ),
    VALUES ( Table1[Client ID] ),
    Table1[Status] = "Validated"
)

20.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @Anonymous,

 

I'd like to suggest you add calculated column to group your records with frequency label, then write a measure to calculate validated records count.

 

Calculate column:

Clusters = 
VAR frequency =
    COUNTROWS (
        FILTER (
            ALL ( Table1 ),
            [Client ID] = EARLIER ( Table1[Client ID] )
                && [Status] = "Validated"
                && FORMAT ( [Datetime], "mm/yyyy" )
                    = FORMAT ( EARLIER ( Table1[Datetime] ), "mm/yyyy" )
        )
    )
RETURN
    IF (
        frequency > 10,
        "More than 10",
        IF (
            frequency > 5 && frequency < 10,
            "between 5 to 10",
            IF ( frequency < 5, "less than 5" )
        )
    )

Measure:

Validated count = 
CALCULATE (
    COUNT ( Table1[Datetime] ),
    VALUES ( Table1[Client ID] ),
    Table1[Status] = "Validated"
)

20.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

The solution works fine! Thanks a lot! 😃

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.