Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello community,
I need your help for this situation. I have a table where I need to calculate with a measure the distribution of a total like this:
Hours | Cost | Amount | Distribute | |
CLIENT 1 | 5,25 | 417,50 | 1.118,90 | |
AREA1 | 1,50 | 105,00 | 701,90 | |
AREA 2 | 1,25 | 62,50 | - | |
AREA 3 | 2,50 | 250,00 | 417,00 | |
Total | 5,25 | 417,50 | 1.118,90 |
The measure have had this formula: Distribute = (Cost * TotalAmount) / TotalCost, for exemeple, in the AREA 1 row, the result would be: (105 * 1,118,90) / 417,50 = 281,40.
I tried this formula:
Distribute =
Var
TotalAMOUNT = CALCULATE(SUM(Table[Amount]);ALLSELECTED(Client[Client]))
TotalCOST = CALCULATE(SUM(Table[Cost]);ALLSELECTED(Client[Client]))
RETURN
(Table[Cost] * TotalAMOUNT) / TotalCOST
What is the measure formula?
Thank you.
Solved! Go to Solution.
Hi Raul,
This should to the trick:
client total cost = calculate(sum(Table1[cost]), ALL(Table1[area]))
client total amount = calculate(sum(Table1[amount]), ALL(Table1[area]))
distribute = (sum([cost])/[client total cost]) * [client total amount]
Hi Raul,
This should to the trick:
client total cost = calculate(sum(Table1[cost]), ALL(Table1[area]))
client total amount = calculate(sum(Table1[amount]), ALL(Table1[area]))
distribute = (sum([cost])/[client total cost]) * [client total amount]
Hello @waltheed,
I found the solution with your help. Only change the table in the ALLSELECTED function and I have the correct result.
Thank you for your answer.
Hello @waltheed,
Thanks for your answer but in my case it is not correct. The Area column is in another table (Table2) related to Table1. When I apply your formula, the result it gives me is this:
Cost | Client Total Cost | |
Client 1 | 417,50 | 417,50 |
Area 1 | 105,00 | 105,00 |
Area 2 | 62,50 | 62,50 |
Area 3 | 250,00 | 250,00 |
Total | 417,50 | 417,50 |
Client Total Cost = CALCULATE(SUM(Table1[Cost]);ALL(Table2[Area]))
And the same with Client Total Amount. What was wrong?
Thank you.
Hi @Raul,
If it is convenient, could you share a dummy pbix file which can reproduce the scenario and your expected output, so that we can help further investigate on it? You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.)
Best Regards,
Cherry
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |