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.
qqqqqwwwweeerrr
2 years agoSolution Sage
Is this what your expectation
if yes this what i have used:
Measure = IF(CONTAINSSTRING(MIN('Table'[Category]),"-") = FALSE(),MIN('Table'[Category]),"Mix")
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Check for more intersing solution here: www.youtube.com/@Howtosolveprobem
Regards
InsightSeeker
2 years agoHelper III
Hi qqqqqwwwweeerrr - I need the result in the column instead of measure
- InsightSeeker2 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_Mathur2 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.