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.
Hi all
Using Power BI for a cost estimate. Now I want to show the impact on the total if certain items' cost were changed. Let's say we have Items 1 to 10, an associated quantity and unit cost.
I have inserted a What if parameter (as a slider) which allows user to provide a new unit cost and then several measures to recalculate the impact. However, this way I have had to hard-code which item it is: i.e.
Solved! Go to Solution.
Hi @jaypatel23
Assuming that you simply want to see a "total-value" (not with items split up into a table/graph) then you can add a slicer with Cost_Table[Item] as value. That way the user can select which item(s) they want to see the change for along with the change in cost.
Then I believe you should be able to use the following measure to calculate the delta-value between the original total cost and the new changed cost (untested):
delta_cost =
VAR Selected_Items = VALUES(Cost_Table[Item])
RETURN
SUMX(
ALL(Cost_Table),
Cost_Table[Quantity]) * Cost_Table[Unit_Cost]
)
- ( SUMX(
FILTER(
ALL(Cost_Table),
NOT(Cost_Table[Item] IN Selected_Items)
),
Cost_Table[Quantity]) * Cost_Table[Unit_Cost]
)
+ SUMX(
Cost_Table,
Cost_Table[Quantity]) * Cost_Table[New_Unit_Cost]
)
)
Please note that I've renamed the column [Unit_Cost] to, yeah, "Unit_Cost", to indicate the column with the old unit cost values in it. The only column that you supplied was the [New_Unit_Cost] which I assume is the parameter.
Hi @jaypatel23 ,
Please refer to my .pbix file.
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @jaypatel23 ,
Please refer to my .pbix file.
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @jaypatel23
Assuming that you simply want to see a "total-value" (not with items split up into a table/graph) then you can add a slicer with Cost_Table[Item] as value. That way the user can select which item(s) they want to see the change for along with the change in cost.
Then I believe you should be able to use the following measure to calculate the delta-value between the original total cost and the new changed cost (untested):
delta_cost =
VAR Selected_Items = VALUES(Cost_Table[Item])
RETURN
SUMX(
ALL(Cost_Table),
Cost_Table[Quantity]) * Cost_Table[Unit_Cost]
)
- ( SUMX(
FILTER(
ALL(Cost_Table),
NOT(Cost_Table[Item] IN Selected_Items)
),
Cost_Table[Quantity]) * Cost_Table[Unit_Cost]
)
+ SUMX(
Cost_Table,
Cost_Table[Quantity]) * Cost_Table[New_Unit_Cost]
)
)
Please note that I've renamed the column [Unit_Cost] to, yeah, "Unit_Cost", to indicate the column with the old unit cost values in it. The only column that you supplied was the [New_Unit_Cost] which I assume is the parameter.
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 |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |