Forum Discussion
Calculate average price based on certain condition
HI Anonymous , thanks so much for supporting, I really appreciate it!
I created the Ranked Table, then I tryed to create the table (Top10Pcttbale) to calculate Cumulative PZ and Filter for Top 10%, but I can't because I get this error:"The first argument of EARLIER/EARLIEST is not a valid column reference in the earlier row context.". Then I created the measure to calculate Weighted Avg Price for Top 10% PZ. But I do not understand the relationship between the three functions. My final aim is to determine the average price of the prices that have a quantity of 10% of the total, for a given period, for a selected product. In the attached tables, the top price 273.28 is the average price of product X for the first quarter, for the total of products that are equal to 10% of the overall total
Hi Nun ,
To calculate the weighted average EUR/pz for the top 10% of total PZ (prioritizing by highest price). I implemented a DAX-based approach and verified the result.
For your reference, I’ve attached the .pbix file so you can review the implementation and DAX measures used.
Please feel free to open the file and explore the visuals and calculations.
Thank you.
- Anonymous1 year agoNot applicable
Hi Nun ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.- Nun1 year ago
Resolver I
Hi,
thanks so much for all the support, I tested the file attached, but the result is not what it should be. Please find enclosed how should be calculated the avg based on the top price with a PZ amount excatly macthing with the 10% of total PZ.
Considering that the 10% is 350, I will take all the agents with till the total is equal to the 10% (A-B-C). now the total doesn't match because it is 370, so from the last will be used 200 (370-350 is 20, so from C=220, to match to 350 we reduct it by 20). Then we need to moltiply the PZ for the EUR/pz, but for agent C will be 200*8,08. The total will be diveded by the 10%(350). The result is 8.767. In the power BI file the Top10Pct_Avg_Price is 9.29. Hope I was clear. Thanks!
- Anonymous1 year agoNot applicable
Hi Nun ,
I’ve reviewed and updated the file. It appears the difference in results was due to a mismatch between your dataset and the one I initially referenced.
The calculations and measures you used were correct—no issues there. The logic was sound; only the data source differed.
I am also including the screenshot for your reference:
Please feel free to open the file and explore the visuals and calculations.
Thank you.