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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
soldous
Advocate II
Advocate II

Applying different weights on each level of hierarchy

Hello,

 

I have PnL fact table like this: fact_table([id],[date],[account_key],[sales_amount]) and dimension for PnL hierarchy like this: dimension_table([account_key],[level_1_name],[level_2_name],[level_2_weight],[level_3_name],[level_3_weight],[level_4_name],[level_4_weight],[level_5_name],[level_5_weight]) relationship between those table is M:N through account_key. 

I need to calculate sum of sales_amount with applying the correct weight when going from a lower level of the hierarchy to a higher one. 

Not all levels for each account is valid -> each level except one can be null.

I tried everything with INSCOPE, RELATED, SWITCH and SUMX but nothing worked for me. 

 

Link to the file here: PBIX 

 

I would very much appreciate any help. 

Thank you very much in advance.

7 REPLIES 7
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

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

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

PBIX file with sample data 

Report with sample data here.

 

Thank you

access denied

I'm sorry. It should be fixed right now. 

Looks like you mixed up your dimension and fact tables?  How are they supposed to correlate?

I didn't. 

In Fact the pnl_acc_chart_key.2 is a FK to the Dimension. In the Dim the same column is not the primary key either. I keep only the necessary columns for the demo. 

The Dim should act as a 5lvl hierarchy of accounts weight should be used when the sum of Custom form Fact goes from lower level to higher.  

Relationship is through pnl_acc_chart_key.2

So this would be the base.  I don't see weights other than 1 and -1.  Is that correct?

 

lbendlin_0-1707776932111.png

Is this what you are after?

 

lbendlin_1-1707777264755.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors