March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi, please for help.
I have table like this, and I need calculate values in column "per of X", it is calculated by formula "per of X = value / X" where X is sum of all values which has in name "x". So X=5+4+3=12
At the report I have slicer for filtering dates. And I need to keep calculation according this filter. So use calculation for all visible values.
Thank you for you ideas
date | name | value | per of X |
01.03.2024 | x1 | 5 | 42% |
07.07.2024 | x2 | 4 | 33% |
07.09.2024 | x3 | 3 | 25% |
17.06.2024 | y1 | 10 | 83% |
25.06.2024 | y2 | 8 | 67% |
09.08.2024 | u1 | 1 | 8% |
11.09.2024 | u2 | 5 | 42% |
X | 12 | ||
Solved! Go to Solution.
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/SUMValue
3\Result
Best Regards,
Bof
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/SUMValue
3\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!
Proud to be a Datanaut!
Private message me for consulting or training needs.
Hi @collinq ,
thank you, but your solution doesn't work. I have attached pictures of report and your calculation. Wha I have wrong?
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
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?
Updated Measure:
Per_of_X =
DIVIDE (
SelectedValue(Table[value]),
[Total_X],
0 // To handle division by zero
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
37 | |
22 | |
20 | |
10 | |
9 |
User | Count |
---|---|
60 | |
56 | |
22 | |
14 | |
12 |