Forum Discussion
Anonymous
2 years agoNot applicable
Split multiple columns into rows using DAX
Hi Jihwan_Kim & other DAX experts, Thanks Jihwan_Kim for your help earlier. My query is, The condition to split is there are multiple columns to be splitting into rows. I have done splitting...
- 2 years ago
Hi,
I am not sure if I understood your question correctly, but please check the below and the attached pbix file.
Expected result table = VAR _t = GENERATESERIES ( 1, 100, 1 ) VAR _pathitem = ADDCOLUMNS ( Data, "@path", SUBSTITUTE ( Data[List of Students], ",", "|" ) ) VAR _pathitemsinging = ADDCOLUMNS ( Data, "@pathsinging", SUBSTITUTE ( Data[Singing], ",", "|" ) ) VAR _pathitemdancing = ADDCOLUMNS ( Data, "@pathdancing", SUBSTITUTE ( Data[Dancing], ",", "|" ) ) VAR _generatetable = FILTER ( GENERATE ( _t, ADDCOLUMNS ( _pathitem, "@Students", PATHITEM ( [@path], [Value] ) ) ), [@Students] <> BLANK () ) VAR _generatesinging = SUMMARIZE ( FILTER ( GENERATE ( _t, ADDCOLUMNS ( _pathitemsinging, "@sing", PATHITEM ( [@pathsinging], [Value] ) ) ), [@sing] <> BLANK () ), Data[ID], Data[Class Name], [@sing] ) VAR _generatedancing = SUMMARIZE ( FILTER ( GENERATE ( _t, ADDCOLUMNS ( _pathitemdancing, "@dance", PATHITEM ( [@pathdancing], [Value] ) ) ), [@dance] <> BLANK () ), Data[ID], Data[Class Name], [@dance] ) RETURN SUMMARIZE ( ADDCOLUMNS ( _generatetable, "@activity", SWITCH ( TRUE (), COUNTROWS ( FILTER ( _generatesinging, Data[ID] = EARLIER ( Data[ID] ) && Data[Class Name] = EARLIER ( Data[Class Name] ) && [@Students] = [@sing] ) ) >= 1 && COUNTROWS ( FILTER ( _generatedancing, Data[ID] = EARLIER ( Data[ID] ) && Data[Class Name] = EARLIER ( Data[Class Name] ) && [@Students] = [@dance] ) ) >= 1, "Sing,Dance", COUNTROWS ( FILTER ( _generatesinging, Data[ID] = EARLIER ( Data[ID] ) && Data[Class Name] = EARLIER ( Data[Class Name] ) && [@Students] = [@sing] ) ) >= 1, "Sing", COUNTROWS ( FILTER ( _generatedancing, Data[ID] = EARLIER ( Data[ID] ) && Data[Class Name] = EARLIER ( Data[Class Name] ) && [@Students] = [@dance] ) ) >= 1, "Dance" ) ), Data[ID], Data[Class Name], [@Students], [@activity] )
Anonymous
2 years agoNot applicable
Hi Anonymous ,
Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.
If these also don't help, please share more detailed information and description to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng