Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello all,
I'm currently binning some records. Say I have products that need to be binned by the amount of revenue each product brings in. Revenue is 0 to 100k, where I'll need 10 bins. Right now, the bin outputs of revenue are 0, 10k, 20k, 30k... etc. How do I have the output of binning be 1, 2, 3.... 10 (representing each number bin)? I can not use the switch function as the values of revenue and distribution will change.
Should look something like this
Revenue | Revenue Bin (Don't want) | Bin Number (Want) |
3000 | 0 | 1 |
16,000 | 10,000 | 2 |
35,000 | 30,000 | 4 |
56,000 | 50,000 | 6 |
87,000 | 80,000 | 9 |
Solved! Go to Solution.
Hi @matsahiro ,
So you should want the effect of dynamic selection.
Here's my workaround.
1.Create two what-if parameters.
2.Create a measure.
Bin Number =
VAR maxbinnum =
SELECTEDVALUE ( 'Bin Range'[Bin Range] )
VAR maxrev =
SELECTEDVALUE ( 'Revenue Range'[Revenue Range] ) * 1000
VAR interval =
DIVIDE ( maxrev, maxbinnum )
RETURN
ROUNDUP ( DIVIDE ( MAX ( 'Table'[Revenue] ), interval ), 0 )
You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @matsahiro ,
So you should want the effect of dynamic selection.
Here's my workaround.
1.Create two what-if parameters.
2.Create a measure.
Bin Number =
VAR maxbinnum =
SELECTEDVALUE ( 'Bin Range'[Bin Range] )
VAR maxrev =
SELECTEDVALUE ( 'Revenue Range'[Revenue Range] ) * 1000
VAR interval =
DIVIDE ( maxrev, maxbinnum )
RETURN
ROUNDUP ( DIVIDE ( MAX ( 'Table'[Revenue] ), interval ), 0 )
You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you very much for your help!
Hi @matsahiro
Not entirely clear. You mention Distribution but don't say how this affects your calculations.
Is this what you need to create a new column?
Bin = SWITCH(
TRUE(),
'Table'[Revenue] < 10000, 1,
'Table'[Revenue] < 20000, 2,
'Table'[Revenue] < 30000, 3,
'Table'[Revenue] < 40000, 4,
'Table'[Revenue] < 50000, 5,
'Table'[Revenue] < 60000, 6,
'Table'[Revenue] < 70000, 7,
'Table'[Revenue] < 80000, 8,
'Table'[Revenue] < 90000, 9,
10
)
Regards
Phil
Proud to be a Super User!
Hello Phil, thanks for the reply! The data is constantly changing, meaning the bin sizes will be different each time the data refreshes. Revenue could be 0 to 100k one day and 0 to 200k the next day. I want to make sure that I always have 20 bins in the visual that are labeled 1-20 even with the bin sizes changing. The reason I cannot use switch in that way is that the bin sizing will change.
User | Count |
---|---|
128 | |
108 | |
99 | |
65 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |