Forum Discussion
percentage calculation
- Anonymous1 year ago
Hi petrk ,
I've made a test for your reference:
1\ I assuem there is a table(Table)
2\Add a measure
Per of X = Var CurrentItemValue =Max('Table'[value]) Var CurrentItemName= LEFT(SELECTEDVALUE('Table'[name]),1) Var SUMValue=CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),LEFT('Table'[name],1)=CurrentItemName)) RETURN CurrentItemValue/SUMValue3\Result
Best Regards,
Bof
Hi petrk ,
You may have better results in the Dax section for Power BI but I will take a run at this. I belive that this is two measures. The first one is to calculate the summation based on the Name colum. So, it will be like this:
SumValue = Calculate(Sum(Table[value]), Allexcept(Table, Table[name]))
Then, the second measure will be to determine what percentage is each individual row against that total:
% = DIVIDE(Table[Value], Table[TotalByName], 0)
Give that a try!
- petrk1 year agoNew Member
Hi collinq ,
thank you, but your solution doesn't work. I have attached pictures of report and your calculation. Wha I have wrong?
- Kedar_Pande1 year agoSuper User
Measure for Sum of X Values:
Total_X =
CALCULATE (
SUM(Table[value]),
FILTER (
Table,
LEFT(Table[name], 1) = "x" // Filters rows where name starts with 'x'
)
)Per of X Measure:
Per_of_X =
DIVIDE (
Table[value],
[Total_X],
0 // To handle division by zero
)If this helped, a Kudos 👍 or Solution mark would be great!
Cheers,
Kedar Pande
www.linkedin.com/in/kedar-pande- petrk1 year agoNew Member
hi Kedar_Pande ,
calculation of Total_X is OK but Per_of_X has issue. PBI doesn't allow me enter Table[value] to formula. It offer me to use just another measures which I have calcalated.
PBI error: A single value for column 'value' in table 'myTable' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
Do you have some idea how to solve it?