Forum Discussion
Premlatapandey9
Microsoft Employee
3 years agoHow to get the Percentage based on Column sum from two different tables
Hello Everyone,
I want to calculate the percentage based on two tables can you please help my data set looks like below
| Table 1 | Table 2 | |||
| Duplicate count | No Duplicate count | |||
| 2 | 1 | |||
| 3 | 2 | |||
| 4 | 3 | |||
| 5 | 4 | |||
| 6 | 5 | |||
| Total T1 | 20 | Total T2 | 15 | |
| Duplicate issues% | Total T1/TotalT2+TotalT1 | 20/20+15 | 57.12 | |
| No Dupe issue% | Total T2/TotalT2+TotalT1 | 15/20+15 | 42.85 | |
Thanks and Regards
@members
2 Replies
- collinq
Super User
Hi Premlatapandey9 ,
In the future, for DAX like this it would be better to use that forum rather than the Service forum. That said - the formula would be this:
Measure = Calculate(Divide(sum(Table2[NoDup]),(sum(Table1[duplicate]))))To get the .75And, to get the 1.33 you would flip that to this:Measure = Calculate(Divide(sum(Table`[duplicate]),(sum(Table2[NoDup]))))But, it appears by your example that you want the percentage of each table against each other with the summation of each column. An easy (althought not elegant) solution is:1. Table1 summation:Table1Sum = Sum(Table1[duplicate])2. Table2 summation:Table2Sum=Sum(Table2[NoDup])3. Combination:TotalofT1andT2 = ((Table1[Table1Sum]+(Table2[Table2Sum])))4. Dividing results:Table1Percentage = Table1[Table1Sum]/Table1[TotalofT1andT2] (is 57)Table2Percentage = Table2[Table2Sum]/Table1[TotalofT1andT2] (is 43) - tackytechtom
Most Valuable Professional
Hi Premlatapandey9 ,
Are you looking for something like this?
Here the code in DAX:
MeasurePerc1 = DIVIDE ( SUM ( Table1[Duplicate count] ), SUM ( Table1[Duplicate count] ) + SUM ( Table2[Duplicate count] ) ) * 100MeasurePerc2 = DIVIDE ( SUM ( Table2[Duplicate count] ), SUM ( Table1[Duplicate count] ) + SUM ( Table2[Duplicate count] ) ) * 100Let me know if this solves your query 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/