Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
hello..
I have 40 columns.
Results #1 | Results #2 | Results #3 | Results # | Results #4 | Results #5 | ABF | GPON | Not available | Light Green |
ABF | NOT available | ABF | ABF | ABF | Light Green | 4 | 1
|
I need a forumla to give the number of times it sees the text "ABF" and then one for another column "GPON" so on and so fourth.
I am going to take these values, then total these in my visual.
I am having a hard time getting the text counted in the columns per row.
The columns in bold are the totals for each choice I am trying to create
Solved! Go to Solution.
HI @karlamaddox1
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]
)
)
HI @karlamaddox1
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.
You may not remember me... but I have posted about this before. THANK YOU!!!!
Hi @karlamaddox1 ,
I'd suggest to unpivot your table in Power Query. For this, go into Power Query, mark all the columns and click on Unpivot Columns:
You should end up with a much longer table than this, but with the same structure:
After you can create a measure like CALCULATE ( COUNT ( 'table'[Value] ), 'table'[Value] = "ABF" ) in DAX.
Would this work out for you? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
I get an error when I unpivot the columns. On attribute and value
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
17 | |
10 | |
10 | |
8 | |
6 |
User | Count |
---|---|
20 | |
18 | |
16 | |
13 | |
10 |