Forum Discussion

TB2's avatar
TB2
New Member
2 years ago
Solved

Top 2 Contribution % calculation

Hi, 

 

I'm trying to calculate the TopN contribution % based on Customer, Branch or Type.

 

CustomerBranchTypeActualBudget
ANYRed$50$120
BCAGreen$250$300
CILBlue$40$150
ANYBlue$80 
CILRed$60 

 

I was able to calculate the Top 2 Customers using :

Top 2 Customers = VAR Top2 = TOPN(2, ALL('Customers'[Customer #]), [Sales Revenue],DESC) RETURN CALCULATE([Sales Revenue], FILTER('Customers', 'Customers'[Customer #] IN Top2))

 

But when I try to calculate the contribution % using :

Top 2 Contribution % = DIVIDE('_Calculations'[Top 2 Customers],'_Calculations'[Sales Revenue])
 
It returns 100% each time I select a customer, branch or type instead of the sales revenue as a percentage of the total revenue.
 
 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi TB2 ,

    Thank you Jihwan_Kim very much for the solution, and I've tried other ways to help you understand the problem:

    For your question, I think your last step could include an all condition to remove the context filtering.

    TOP 2 Contribution % = DIVIDE('Table'[Top 2 Customers],CALCULATE('Table'[sales revenge],ALL('Table')))

    Hope it helps!

     

    Best regards,
    Community Support Team_ Tom Shen

     

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

     

     

3 Replies

  • foodd's avatar
    foodd
    Community Champion

    Hello TB2 , and thank you for sharing your question with the Community.  Please remember to adhere to the decorum of the Community Forum when asking a question.

    Please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot).  You can upload the PBIX file to a cloud storage service such as OneDrive, Google Drive, Dropbox, or to a Github repository, and then share the file’s URL.

    https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216

    Please show the expected outcome based on the sample data you provided.

    https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523/highlight/true#M607150

    This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.

     

     

  • Hi,

    I am not sure if I understood your question correctly, but please try something like below whether it suits your inquiry.

     

    Top 2 Contribution % =
    DIVIDE (
        [Top 2 Customers],
        CALCULATE ( [Sales Revenue], ALLSELECTED ( 'Customers'[Customer #] ) )
    )
    
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi TB2 ,

    Thank you Jihwan_Kim very much for the solution, and I've tried other ways to help you understand the problem:

    For your question, I think your last step could include an all condition to remove the context filtering.

    TOP 2 Contribution % = DIVIDE('Table'[Top 2 Customers],CALCULATE('Table'[sales revenge],ALL('Table')))

    Hope it helps!

     

    Best regards,
    Community Support Team_ Tom Shen

     

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