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
Sarevem
Frequent Visitor

Group data based on % to total

Hi! 

 

I have invoice level sales data - by account and item - for the past 3 years. I have used time intelligence to create measures such as 'latest 26 week sales' and 'year-to-date sales'. 

 

I've looked at both the percentilex and TopN functions and haven't been able to get them to accomplish my end goal precisely.

 

Essentially, I want to be able to group data based on % of total. For example: X accounts drove top 25% of sales, X accounts drove the next 25-50% of sales. The number of accoutns or items is always going to vary based on the timeframe I'm looking at or filters I apply limiting me from using TopN. 

I'm assuming I need to use some type of rank formula? I've been rather stumped on the best way to segment my data. 

 

Account NameYTD Sales% to total
Account 1 10403.1%
Account 26411.9%
Account 35791.7%
Account 45101.5%
Account 54821.4%
Account 64201.2%
Account 74031.2%
Account 83891.1%
Account 93721.1%
Account 103621.1%
Account 113581.1%
Account 123511.0%
Account 132970.9%
Account 142890.9%
Account 152620.8%
Account 162480.7%
Account 172440.7%
Account 182410.7%
Account 192310.7%
Account 202270.7%

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @Sarevem

 

How about a Cumulative % to total....ordered from Account with highest sales to lowest

This will give you an idea of how many Account accumulate upto 25% or 50% etc of the total sales

 

you can first add a MEASURE to RANK the accounts

 

RANK =
RANKX (
    ALL ( TableName[Account Name] ),
    CALCULATE ( SUM ( TableName[YTD Sales] ) ),
    ,
    DESC,
    DENSE
)

Then the following MEASURE will give you Cumulative %age to total

 

Cumulative % to Total =
VAR CurrentRANK = [RANK]
RETURN
    DIVIDE (
        CALCULATE (
            SUM ( TableName[YTD Sales] ),
            FILTER ( ALL ( TableName[Account Name] ), [RANK] <= CurrentRANK )
        ),
        CALCULATE ( SUM ( TableName[YTD Sales] ), ALL ( TableName[Account Name] ) )
    )

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @Sarevem

 

How about a Cumulative % to total....ordered from Account with highest sales to lowest

This will give you an idea of how many Account accumulate upto 25% or 50% etc of the total sales

 

you can first add a MEASURE to RANK the accounts

 

RANK =
RANKX (
    ALL ( TableName[Account Name] ),
    CALCULATE ( SUM ( TableName[YTD Sales] ) ),
    ,
    DESC,
    DENSE
)

Then the following MEASURE will give you Cumulative %age to total

 

Cumulative % to Total =
VAR CurrentRANK = [RANK]
RETURN
    DIVIDE (
        CALCULATE (
            SUM ( TableName[YTD Sales] ),
            FILTER ( ALL ( TableName[Account Name] ), [RANK] <= CurrentRANK )
        ),
        CALCULATE ( SUM ( TableName[YTD Sales] ), ALL ( TableName[Account Name] ) )
    )

Regards
Zubair

Please try my custom visuals

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.