The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
We need help in computing the weekly cost of each fruit, but needs to recompute it if both fruits are harvested on the same day.
Sample April 15 (highlighted in yellow), Fruit 1 and Fruit 2 both have the same cost of 4600 for this day but have different weight.
We are able to compute the new cost however we want the total to be the sum of the new cost + existing cost not the output by the new cost as seen in the right most part of the photo.
Any tips on how to compute this please.
Solved! Go to Solution.
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
daily cost old: =
SWITCH (
TRUE (),
HASONEVALUE ( fruit[fruit] ), SUMX ( VALUES ( 'calendar'[date] ), CALCULATE ( MAX ( data[cost] ) ) ),
SUMX (
VALUES ( 'calendar'[date] ),
CALCULATE ( MAX ( data[cost] ), ALL ( fruit[fruit] ) )
)
)
daily cost new (weighted cost): =
SUMX (
VALUES ( 'calendar'[date] ),
SUMX (
SUMMARIZE ( data, fruit[fruit] ),
CALCULATE (
DIVIDE (
SUM ( data[weight] ),
CALCULATE ( SUM ( data[weight] ), ALL ( fruit[fruit] ) )
)
* SUM ( data[cost] )
)
)
)
All cost: =
[daily cost old:] + [daily cost new (weighted cost):]
Thankyou @Jihwan_Kim for providing the solution.
Hi @non23 ,
we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.
Regards,
Chaithanya.
Thankyou @Jihwan_Kim for providing the solution.
Hi @non23 ,
we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.
Regards,
Chaithanya.
Hi,
I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
daily cost old: =
SWITCH (
TRUE (),
HASONEVALUE ( fruit[fruit] ), SUMX ( VALUES ( 'calendar'[date] ), CALCULATE ( MAX ( data[cost] ) ) ),
SUMX (
VALUES ( 'calendar'[date] ),
CALCULATE ( MAX ( data[cost] ), ALL ( fruit[fruit] ) )
)
)
daily cost new (weighted cost): =
SUMX (
VALUES ( 'calendar'[date] ),
SUMX (
SUMMARIZE ( data, fruit[fruit] ),
CALCULATE (
DIVIDE (
SUM ( data[weight] ),
CALCULATE ( SUM ( data[weight] ), ALL ( fruit[fruit] ) )
)
* SUM ( data[cost] )
)
)
)
All cost: =
[daily cost old:] + [daily cost new (weighted cost):]
User | Count |
---|---|
27 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
7 | |
6 |