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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.