Forum Discussion
InsightSeeker
2 years agoHelper III
Need help with DAX formula
I need help to achieve the results shown in the table below. Essentially, in the 'Category' column, if all the values are the same, then return the first value; otherwise, return 'Mix...
- 2 years ago
Hi,
This calculated column formula works
Column = if(SUBSTITUTE(SUBSTITUTE(Data[Category],"-",BLANK()),LEFT(Data[Category],SEARCH("-",Data[Category],,20)-1),BLANK())="",LEFT(Data[Category],SEARCH("-",Data[Category],,20)-1),"Mix")Hope this helps.
InsightSeeker
2 years agoHelper III
Hi qqqqqwwwweeerrr - Your result is not correct.
Below is the result i am looking for.
If all values are same then return the first value for example if the values are
Apple or
Apple-Apple or
Apple-Apple-Apple-Apple..... then return of Apple
If the values are
Apple-Grapes or
Apple-Grapes-Grapes-Apple then return of Mix
Result
| Category | Result |
| Apple-Apple | Apple |
| Apple-Grapes | Mix |
| Apple | Apple |
| Grapes-Grapes | Grapes |
| Grapes-Apple-Apple-Grapes | Mix |
| Grapes | Grapes |
Ashish_Mathur
2 years agoSuper User
Hi,
This calculated column formula works
Column = if(SUBSTITUTE(SUBSTITUTE(Data[Category],"-",BLANK()),LEFT(Data[Category],SEARCH("-",Data[Category],,20)-1),BLANK())="",LEFT(Data[Category],SEARCH("-",Data[Category],,20)-1),"Mix")
Hope this helps.