Forum Discussion
Count Text in Columns
- 4 years ago
HI Anonymous
The only way I could think of to unpivot the table using DAX is by hard coding the 40 columns. However, Power Query does it the same way, the only difference is that it generates the code automatically for you but in DAX you need to write it yourself.
I understand the disaster you went through when attempting to unpivot using Power Query therefore, please keep a backup copy before trying this with DAX. In general DAX is faster than Power Query and this code contains only two functions, UNION and SELECTCOLUMNS which are the fastest functions in DAX. Yet this might consume a significant amount of execution time for your big data to be processed but it is unlikely to crash.
The code is a repetition of a SELECTCOLUMNS statement (highlighted in green) that you need to copy and paste 40 times. Only the ones highlighted in red are the ones that you need to edit. Once you do that it would be easy to sum and count based on any filters you wish. (Please provide more details about the desired results and perhaps provide sample data to work with. Have a great day.Ticketing Upivoted = UNION ( SELECTCOLUMNS ( Ticketing, "Result", Ticketing[Results #1], "Result 2", Ticketing[Results #2], "Result 3", Ticketing[Results #3], "Result 4", Ticketing[Results #4], "Result 5", Ticketing[Results #5], "Result#", Ticketing[Results #], "Attribute", "ABF", "Value", Ticketing[ABF] ), SELECTCOLUMNS ( Ticketing, "Result", Ticketing[Results #1], "Result 2", Ticketing[Results #2], "Result 3", Ticketing[Results #3], "Result 4", Ticketing[Results #4], "Result 5", Ticketing[Results #5], "Result#", Ticketing[Results #], "Attribute", "GPON", "Value", Ticketing[GPON] ), SELECTCOLUMNS ( Ticketing, "Result", Ticketing[Results #1], "Result 2", Ticketing[Results #2], "Result 3", Ticketing[Results #3], "Result 4", Ticketing[Results #4], "Result 5", Ticketing[Results #5], "Result#", Ticketing[Results #], "Attribute", "Not availabl", "Value", Ticketing[Not available] ), SELECTCOLUMNS ( Ticketing, "Result", Ticketing[Results #1], "Result 2", Ticketing[Results #2], "Result 3", Ticketing[Results #3], "Result 4", Ticketing[Results #4], "Result 5", Ticketing[Results #5], "Result#", Ticketing[Results #], "Attribute", "Light Green", "Value", Ticketing[Light Green] ) )
I ended up being able to unpiviot the columns because of you
But that after I caused your file to crash. Sorry for that again.