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
JLiljedahl
Helper I
Helper I

TopN Share of total

Hi 

 

I have "inherited" a PBI report from a former collegue with a funtion of ranking topN customer by sales

 

I now need to do the same thing but instead of sales value in € I want to display sales share per customer in %. Anyone who could support me in rewrite below code for this application?

 

Sales Amt =
Var SalesOfAll=
    CALCULATE([Total Sales],REMOVEFILTERS(GroupCustomer[GroupCustomer]))
Return
    IF(
        ISINSCOPE(GroupCustomer[GroupCustomer]),
        VAR ProductsToRank = 'TopN'[Value for TopN]
        VAR IsOtherSelected = SELECTEDVALUE(GroupCustomer[GroupCustomer])="Others"
        VAR ProductsWithSalesAmt =
            ADDCOLUMNS(
                ALLSELECTED(GroupCustomer[GroupCustomer]),
                "@Amt", [Total Sales]
            )
        VAR Top3Prods = TopN (ProductsToRank,ProductsWithSalesAmt,[@Amt])
        VAR SalesOfTop3 = SUMX(Top3Prods,[@Amt])
        VAR Result = IF(IsOtherSelected,SalesOfAll-SalesOfTop3,[Total Sales])
        Return Result,
        SalesOfAll
    )
1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @JLiljedahl 
Please refer to the linked tutorial :

https://www.youtube.com/watch?v=jyKAxKSHBTk

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
Ritaf1983
Super User
Super User

Hi @JLiljedahl 
Please refer to the linked tutorial :

https://www.youtube.com/watch?v=jyKAxKSHBTk

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.