Forum Discussion
Grouping prices in %
- Anonymous4 years ago
Hi
According to your description, you firstlt need to create a table with a column that has value:
"0-10%", "10-20%", "20-30%","30-40%", ... It will be used for X-axis.- For X-axis = {"0-10%", "10-20%", "20-30%","30-40%", "40-50%","50-60%", "60-70%", "70-80%","80-90%","90-100%"}
Then calculate the percentage, and use SWITCH() to match the percentage name and the count of corresponding percentage:
- Percentage = DIVIDE(MAX('OnlinePrices'[Online Price]),MAX('Products'[Recommended Price]))
- Measure =
var _1=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>=0 && [Percentage]<=0.1))
var _2=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.1 && [Percentage]<=0.2))
var _3=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.2 && [Percentage]<=0.3))
var _4=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.3 && [Percentage]<=0.4))
var _5=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.4 && [Percentage]<=0.5))
var _6=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.5 && [Percentage]<=0.6))
var _7=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.6 && [Percentage]<=0.7))
var _8=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.7 && [Percentage]<=0.8))
var _9=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.8 && [Percentage]<=0.9))
var _10=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.9 &&[Percentage]<=1))
return SWITCH(MAX('For X-axis'[Value]),"0-10%", _1, "10-20%",_2, "20-30%",_3, "30-40%",_4, "40-50%",_5,"50-60%",_6, "60-70%", _7,"70-80%",_8,"80-90%",_9,"90-100%",_10)
The final output:
Best Regards,
Eyelyn QinIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi
According to your description, you firstlt need to create a table with a column that has value:
- For X-axis = {"0-10%", "10-20%", "20-30%","30-40%", "40-50%","50-60%", "60-70%", "70-80%","80-90%","90-100%"}
Then calculate the percentage, and use SWITCH() to match the percentage name and the count of corresponding percentage:
- Percentage = DIVIDE(MAX('OnlinePrices'[Online Price]),MAX('Products'[Recommended Price]))
- Measure =
var _1=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>=0 && [Percentage]<=0.1))
var _2=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.1 && [Percentage]<=0.2))
var _3=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.2 && [Percentage]<=0.3))
var _4=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.3 && [Percentage]<=0.4))
var _5=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.4 && [Percentage]<=0.5))
var _6=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.5 && [Percentage]<=0.6))
var _7=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.6 && [Percentage]<=0.7))
var _8=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.7 && [Percentage]<=0.8))
var _9=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.8 && [Percentage]<=0.9))
var _10=CALCULATE(COUNTROWS('OnlinePrices'),FILTER('OnlinePrices',[Percentage]>0.9 &&[Percentage]<=1))
return SWITCH(MAX('For X-axis'[Value]),"0-10%", _1, "10-20%",_2, "20-30%",_3, "30-40%",_4, "40-50%",_5,"50-60%",_6, "60-70%", _7,"70-80%",_8,"80-90%",_9,"90-100%",_10)
The final output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks this seems to work great!