Forum Discussion
Data Modeling with 2 Fact Tables
I have the following 2 Tables :-
Account Details
Person Details
Now each account can have multiple persons associated with it and one person can manage multiple accounts
Let's take the below example :-
I also have a Top N filter table where I have values for each Top N%
The above table means that when I select Top 50%, I need to select the top 50% accounts by revenue , within the context of other filters like Area
I am trying to do the following :-
1. When user selects a Top N% Value (Let's say Top 50%) , a visual should return the top N% accounts by revenue
2. Upon the same action, another visual should return the list of persons who are associated with the account and their Target and Actual (Ideally 1 row per person)
I am wondering what would be a good way to model the data to achieve this , since it looks like I am filtering dimension tables(AccountId) based on filtering on Fact Tables.
Appreciate any help and guidance
- Anonymous5 years ago
Hi Anonymous ,
1.Create a calculated column to rank.
Rank = RANKX ( 'Account Details', CALCULATE ( SUM ( 'Account Details'[Revenue] ), ALLEXCEPT ( 'Account Details', 'Account Details'[AccountID] ) ), , ASC, DENSE )2.Create a measure and put it into Filters. Set show items when the value is 1.
Measure = VAR maxrank = CALCULATE ( MAX ( 'Account Details'[Rank] ), ALL ( 'Account Details' ), ALL ( 'Person Details' ) ) RETURN SWITCH ( SELECTEDVALUE ( 'Top N filter'[TOp N%] ), "ALL", 1, "Top1%", IF ( MIN ( 'Account Details'[Rank] ) < maxrank * 0.01, 1 ), "Top5%", IF ( MIN ( 'Account Details'[Rank] ) < maxrank * 0.05, 1 ), "Top50%", IF ( MIN ( 'Account Details'[Rank] ) < maxrank * 0.5, 1 ) )3.When Top50% is selected, the result is this.
You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- CNENFRNLCommunity Champion
Hi, Anonymous , what you mention is a typical many-to-many relationship. You may want to refer to such guidances on this topic in detail.
https://docs.microsoft.com/en-us/power-bi/guidance/relationships-many-to-many
https://www.burningsuit.co.uk/blog/2019/07/dealing-with-many-to-many-relationships/
https://www.seerinteractive.com/blog/join-many-many-power-bi/
- amitchandakSuper User
Anonymous , Not very clear.
I think you need percentile
https://blog.enterprisedna.co/implementing-80-20-logic-in-your-power-bi-analysis/
https://forum.enterprisedna.co/t/testing-the-pareto-principle-80-20-rule-in-power-bi-w-dax/459
https://finance-bi.com/power-bi-pareto-analysis/
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Calculate-the-sum-of-the-top-80/td-p/763156Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
- AnonymousNot applicable
Hi Anonymous ,
1.Create a calculated column to rank.
Rank = RANKX ( 'Account Details', CALCULATE ( SUM ( 'Account Details'[Revenue] ), ALLEXCEPT ( 'Account Details', 'Account Details'[AccountID] ) ), , ASC, DENSE )2.Create a measure and put it into Filters. Set show items when the value is 1.
Measure = VAR maxrank = CALCULATE ( MAX ( 'Account Details'[Rank] ), ALL ( 'Account Details' ), ALL ( 'Person Details' ) ) RETURN SWITCH ( SELECTEDVALUE ( 'Top N filter'[TOp N%] ), "ALL", 1, "Top1%", IF ( MIN ( 'Account Details'[Rank] ) < maxrank * 0.01, 1 ), "Top5%", IF ( MIN ( 'Account Details'[Rank] ) < maxrank * 0.05, 1 ), "Top50%", IF ( MIN ( 'Account Details'[Rank] ) < maxrank * 0.5, 1 ) )3.When Top50% is selected, the result is this.
You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.