Forum Discussion
Anonymous
2 years agoNot applicable
DAX to Create 2 Custom columns based on a selected value
Hello Members, I am looking help with a DAX to create2 custom columns based on inputs from original field. there are mulitple values in the field which- 1)- have to grouped based on a filter ...
- 2 years ago
hi, Anonymous
Add two columns in your current table
try below column codeoutpu_field1= VAR a = SEARCH(";",'Table (2)'[Current Input Column]) return LEFT('Table (2)'[Current Input Column],a-1)output_field2= VAR a = SEARCH(";",'Table (2)'[Current Input Column]) var b = LEN('Table (2)'[Current Input Column]) return RIGHT('Table (2)'[Current Input Column],b-a)and it easy in power query
use split column
- Anonymous2 years ago
Hi Anonymous
Dangar332 , thanks for your contribution to the forum
Just as he posted that you can add 2 calculate column.
And I'll add some details on his basis:
First of all, I create a new table:
Table2 = SELECTCOLUMNS ( 'Table', "outpu_field", LEFT ( 'Table'[Current Input], SEARCH ( ";", 'Table'[Current Input] ) - 1 ) )Then add a new measure:
Output = VAR _newtable = SELECTEDVALUE ( Table2[outpu_field] ) VAR _newoutput = SWITCH ( _newtable, "AAAAA", "AAAAA", "BBBBBB", "BBBBBB", "FFFFFFFF", "FFFFFFFF" ) RETURN CONCATENATEX ( ALL ( 'Table' ), CALCULATE ( SELECTEDVALUE ( 'Table'[output_field2] ), 'Table'[output_field1] = _newoutput ), " " )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dangar332
Resident Rockstar
2 years agohi, Anonymous
Add two columns in your current table
try below column code
outpu_field1=
VAR a = SEARCH(";",'Table (2)'[Current Input Column])
return
LEFT('Table (2)'[Current Input Column],a-1)
output_field2=
VAR a = SEARCH(";",'Table (2)'[Current Input Column])
var b = LEN('Table (2)'[Current Input Column])
return
RIGHT('Table (2)'[Current Input Column],b-a)
and it easy in power query
use split column