Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello Community,
I created a grouping based on the price of a good to be used on the axis of different visuals.
I created the groups by writing a SWITCH(TRUE()) statement because I want the group name to be the range and not just the first number in the range.
Here is my DAX:
SWITCH(
TRUE(),
'Table'[Item Price] <= 0, "<= 0 kr",
'Table'[Item Price] < 10, "0-9 kr",
'Table'[Item Price] < 20, "10-19 kr",
...
)
But when I apply this column in a visual, the labels are not grouped but is rather being read as different labels:
In 'Data view' when filtering, the value is recognized as being the same value.
I tried filtering the table on the same value I selected in the above screenshot and it is counted as a single distinct value:
Solved! Go to Solution.
Still not sure what has caused this but I ended up tweaking the underlying DAX behind bins for my purpose:
VAR _RDown = ROUNDDOWN( 'Table'[Item Price] / 10, 0 ) * 10
VAR _RUp = ROUNDUP( 'Table'[Item Price] / 10, 0 ) * 10
VAR _RUpCheck = IF(_RDown = _RUp, _RUp + 10, _RUp)
RETURN
IF(
ISBLANK( 'Table'[Item Price] ),
"N/A",
IF( 'Table'[Item Price] < 0, "N/A",
IF(
'Purchase'[Item Price] >= 0,
CONCATENATE(
_RDown,
CONCATENATE( "-",
_RUpCheck
)
)
)
)
)
Seems to work allright but I'm still testing tho.
Still not sure what has caused this but I ended up tweaking the underlying DAX behind bins for my purpose:
VAR _RDown = ROUNDDOWN( 'Table'[Item Price] / 10, 0 ) * 10
VAR _RUp = ROUNDUP( 'Table'[Item Price] / 10, 0 ) * 10
VAR _RUpCheck = IF(_RDown = _RUp, _RUp + 10, _RUp)
RETURN
IF(
ISBLANK( 'Table'[Item Price] ),
"N/A",
IF( 'Table'[Item Price] < 0, "N/A",
IF(
'Purchase'[Item Price] >= 0,
CONCATENATE(
_RDown,
CONCATENATE( "-",
_RUpCheck
)
)
)
)
)
Seems to work allright but I'm still testing tho.
Hi @BIanon ,
Thanks for your feedback and sharing your solution here. If your solution works well, could you please mark your post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.
Best Regards
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
96 | |
93 | |
82 | |
70 | |
64 |
User | Count |
---|---|
115 | |
105 | |
95 | |
79 | |
72 |