cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kostask
Helper I
Helper I

Calculate the ranking and cumulative contribution in calculated columns

Hi guys!

 

I'm trying to figure out the following problem, by creating calculated columns on my original table, and not measures.

 

a.PNG

 

 

 

 

 

 

 

 

So I have many rows with sold materials. Each row contains material and sales amount (B).

I created the total sales by material (C)  which came to every row.

I also created the material's contribution to total sales (D) for every row also.

 

What I miss, is to create the ranking of every material based on its contribution (Column E) and finally (I guess the most tricky) the cumulative contribution of every material, based on its ranking (1st, 1st+2nd, 1st+2nd+3rd, etc..)

 

Any help would be appreciated

 

Thanx

Kostas

5 REPLIES 5
TarunSharma
Responsive Resident
Responsive Resident

Hello @kostask 
You can try this formula.
Cumulative materials =
VAR CurrentRank = 'Sales'[Material Ranking]
RETURN
CALCULATE (
SUM ( Material Contribution ),
FILTER ( Sales, 'Sales'[Material Ranking] <= CURRENTRANK )
)

How to get your question answered quickly 

SanketBhagwat
Responsive Resident
Responsive Resident

Hi @kostask .

To calculate Ranking of material you can use,
Rank=RANKX(table,table[Material Contribution]).
 

 

daxer
Solution Sage
Solution Sage

Actually, the remaining calculations are not too difficult but why don't you calculate all of this in Power Query?

@daxer, I want to create calculated columns, because I want after that to apply some filter scenarios, and for me is easier to handle. If you could calculate the cumulative materials contribution based on ranking (column f) you would help me a lot.
thanx

Kostas

@kostask 

 

Calculated columns, especially in fact tables, should be avoided at all costs because such columns do not participate in the data compressing phase and thus they tables are not optimally compressed, hence DAX queries will not run at the maximum speed possible. This rule is especially important in models with fact tables that contain millions and millions of rows. Columns should always be calculated either in the source system and then brought over into Power BI or they should be calculated in Power Query (that's what this tool is for). Surely it's not hard at all to do all your calculations in Power Query. I could create the code for you but not right now as I'm at work 🙂 If you wait a bit, I'll give you M code that you'll be able to use in Power Query on your data. Up to you.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.