
Hi,
I am trying to group results in ranges, something like below
My current approach is creating a calculated field which basically assumes that the bin size is 4.
below is the relevant calculated field code
IF [GetGroupByAttiribute] >= 0 AND [GetGroupByAttiribute] < [Bin1UpperLimit] THEN "0 to " + [Bin1UpperLimitToStr]
ELSEIF [GetGroupByAttiribute] >= [Bin1UpperLimit] AND [GetGroupByAttiribute] < [Bin2UpperLimit] THEN [Bin1UpperLimitToStr] + " to " + [Bin2UpperLimitToStr]
ELSEIF [GetGroupByAttiribute] >= [Bin2UpperLimit] AND [GetGroupByAttiribute] < [Bin3UpperLimit] THEN [Bin2UpperLimitToStr] + " to " + [Bin3UpperLimitToStr]
ELSEIF [GetGroupByAttiribute] >= [Bin3UpperLimit] AND [GetGroupByAttiribute] < [Bin4UpperLimit] THEN [Bin3UpperLimitToStr] + " to " + [Bin4UpperLimitToStr]
END
As you see, I am hard coding [Bin1UpperLimit], [Bin2UpperLimitToStr], [Bin3UpperLimitToStr] and so on.
Is it possible to make this generic and not have the hardcoding as above, so as of now, if we had to change the number of bins to 5 or 3, the code for calculated field also needs to change.
Can we make this generic?
Thanks.
Just give it a try - I would use some code (probably an LOD) based on measures in the data to calculate the upper and lower limit - and include a condition or filter in the LOD (placing the dimension in Context) to set the limits -
when you have a tableau workbook that includes that effort then post it here in TWBX form along with you specific question for more help