Forum Discussion
Need Calculated Column to compute dynamically Range based on Slicers selection
- 6 years ago
Hi, Mond,
you can achieve this by creating a measure which has as sole purpose to filter the range-table:
RangeFilterMeasure = var _sumQty=SUM(customer[Qty]) return SWITCH( TRUE(); _sumQty >= 2000 && SELECTEDVALUE(Range[Range])=">=2000";1; _sumQty >= 1000 && _sumQty < 2000 && SELECTEDVALUE(Range[Range])="1000 - <2000";1; _sumQty >= 500 && _sumQty < 1000 && SELECTEDVALUE(Range[Range])="500 - <1000";1; _sumQty >= 100 && _sumQty < 500 && SELECTEDVALUE(Range[Range])="100 - <500";1; _sumQty >= 0 && _sumQty < 100 && SELECTEDVALUE(Range[Range])="<100";1; 0 )Add this RangeFilterMeasure to the filter pane of your visual and set it to filter on RangeFilterMeasure=1. Add 'Range'[Range] to the legend field of your pie chart, and e.g. date to the details-field. I have created an example for you.
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too. - 6 years ago
The above suggestion seems fine. But if you want to fix the range at customer level, You have to do small change.
refer :https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013
RangeFilterMeasure = var _sum= SUM (customer[Qty] ), ALLEXCEPT ( 'Customer','Customer'[ID]) return SWITCH( TRUE(); _sum >= 2000 && SELECTEDVALUE(Range[Range])=">=2000";1; _sum >= 1000 && _sumQty < 2000 && SELECTEDVALUE(Range[Range])="1000 - <2000";1; _sum >= 500 && _sumQty < 1000 && SELECTEDVALUE(Range[Range])="500 - <1000";1; _sum >= 100 && _sumQty < 500 && SELECTEDVALUE(Range[Range])="100 - <500";1; _sum >= 0 && _sumQty < 100 && SELECTEDVALUE(Range[Range])="<100";1; 0 )Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
The above suggestion seems fine. But if you want to fix the range at customer level, You have to do small change.
refer :https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013
RangeFilterMeasure =
var _sum= SUM (customer[Qty] ),
ALLEXCEPT ( 'Customer','Customer'[ID])
return
SWITCH(
TRUE();
_sum >= 2000 && SELECTEDVALUE(Range[Range])=">=2000";1;
_sum >= 1000 && _sumQty < 2000 && SELECTEDVALUE(Range[Range])="1000 - <2000";1;
_sum >= 500 && _sumQty < 1000 && SELECTEDVALUE(Range[Range])="500 - <1000";1;
_sum >= 100 && _sumQty < 500 && SELECTEDVALUE(Range[Range])="100 - <500";1;
_sum >= 0 && _sumQty < 100 && SELECTEDVALUE(Range[Range])="<100";1;
0
)
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
Thank you so much for further ideas.
I need to find out DISTINCTCOUNT on customers with same Qty Range.
How many fall under Qty Range ?
Thanks once again for support !!