Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi. I have a following DAX code to calculate percentage of a component (by dividing quantity of component with total). Table fileds are (ID, quantity, factor and component). I use my DAX code as measure which works great as long as visualisation is based only on this table only but has certain problems when trying to visualize data from other related tables.
Component_percentage =
VAR Divide =
CALCULATE (
SUM ( 'Table1'[Quantity]] ),
FILTER (
ALLEXCEPT ( 'Table1', 'Table1'[ID] ),
'Table1'[Component] = "Total"
)
)
RETURN
IF (
SUM ( 'Table1'[Factor] ) = 1,
SUM ( 'Table1'[Quantity]] ) / Divide,
0
)
I could solve this by adding new column in M code instead of using DAX measure. However, I am having problems with defining it. Can you propose a solution?
Solved! Go to Solution.
@davidz106 , In power query you have duplicate table, Filter it and the use group by- https://docs.microsoft.com/en-us/power-query/group-by
In that you ill get the total column
Merge the tables and you the line value and sub total
Divide into a new column
merge : https://radacad.com/append-vs-merge-in-power-bi-and-power-query
@davidz106 , In power query you have duplicate table, Filter it and the use group by- https://docs.microsoft.com/en-us/power-query/group-by
In that you ill get the total column
Merge the tables and you the line value and sub total
Divide into a new column
merge : https://radacad.com/append-vs-merge-in-power-bi-and-power-query
User | Count |
---|---|
84 | |
76 | |
74 | |
48 | |
39 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |