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

create a pie chart with categories that change with date slicer

Hi,

I have data with customer ids where each row represents transaction info. I am supposed to find average transaction per day for each customer. There is a slicer for date where I can choose last 30 days, or last 7 days. According to the chosen dates, avg per day gets changed. If I just use existing table, there exists an issue of finding correct average. For example, a customer did 10 transactions in only 5 days among our chosen 30 days. We get average here 10/5 instead of 10/30. The only way to solve this is by creating a measure using another table called calender, having one to many relationship with date of existing table. It solves the problem.

 

Now, I need to make a pie chart with categories like less than 0.5 transaction per day on avg, less than 1, less than 2, more than 5 etc. How can I create such categories using just the measure "avg per day". As we can not make a column in the table as avg per day because the column of avg values in the table doesnt change with slicer date (as discussed before eg, last 30 days or last 7 days). I could not figure out how to make categories in pie chart using just a measure here or a table that will change the average values with date slicer. Kindly help me in this!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
You can create a segmentation table ('Buckets') that looks like

Segment Lower Limit Upper Limit
< 0.5 0 0.5
< 1.0 0 1
< 2 0 2
> 2 2 9999999999
> 5 5 9999999999

You can place Buckets[Segment] in the pie chart along with the following measure

Number of Customers =
AVERAGEX (
    Buckets,
    SUMX (
        VALUES ( Data[Customer ID] ),
        VAR AvgPerDay = [avg per day]
        RETURN
            INT ( AvgPerDay >= Buckets[Lower Limit] && AvgPerDay < Buckets[Upper Limit] )
    )
)

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @Anonymous 
You can create a segmentation table ('Buckets') that looks like

Segment Lower Limit Upper Limit
< 0.5 0 0.5
< 1.0 0 1
< 2 0 2
> 2 2 9999999999
> 5 5 9999999999

You can place Buckets[Segment] in the pie chart along with the following measure

Number of Customers =
AVERAGEX (
    Buckets,
    SUMX (
        VALUES ( Data[Customer ID] ),
        VAR AvgPerDay = [avg per day]
        RETURN
            INT ( AvgPerDay >= Buckets[Lower Limit] && AvgPerDay < Buckets[Upper Limit] )
    )
)

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.

Top Solution Authors