Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello Community,
I have a table that looks like this:
Workflow # | Requester | Approver1 | Approver2 | Processor1 | Processor2 | Processor3 |
12345 | Bob | Jim | NULL | Mary | NULL | NULL |
12346 | Bob | Frank | Sarah | Janet | Mary | NULL |
12347 | Bill | Mary | Jim | Nancy | Jake | Bob |
What I want is to know how many times someone's "touched" something, basically if a name shows up in ANY field (Requester, Approver1, Approver2, Processor1, Processor2, Processor3), to count that Workflow Number towards their total. So the result (ideally) would look like this:
Name | Workflow Count |
Bob | 3 |
Jim | 2 |
Mary | 3 |
Frank | 1 |
Janet | 1 |
Bill | 1 |
Nancy | 1 |
Jake | 1 |
Since Bob's name showed up on each line item (doesn't matter which column), he gets a count of 3 workflows, Jim 2 etc. Each line item is based on Workflow Number (it's my primary key, so all unique values). How do I populate those names spread out across multiple fields, condense it into a singular column, and then show how many times their names were associated with a workflow (e.g. Jim is approver1 for workflow #12345 and approver for workflow #12347, so his count is 2). If it helps, if a name is in one of the fields it'll unlikely be repeated. Please help, thanks!
Solved! Go to Solution.
@Anonymous best way to achieve this would be to unpivot your table.
in query editor, click workflow #, right click and select "unpivot other columns"
you will get two column "attribute" and "value", rename value to "name", apply the changes.
in table visual, drop name and workflow # and change the aggregation to workflow # to count, and you will get the result.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi there, OP here: Turns out the "Unpivot Other Columns" Power Query M solution, while valid, only works on import tables and not DirectQuery. However I could use UNPIVOT() on the SQL side to get the results how I wanted and just import the results table. This is my query
select B.Name,count(workflow_number) as Workflow_Count
from (
select Workflow_Number, Position, Name
from Workflow_Table
UNPIVOT(
Name
FOR Position in (Requester, Approver1, Approver2, Processor1, Processor2, Processor3)
) AS A
) as B
Group by Name
order by name asc
which give me output like this (Which is what I wanted):
Name WF_Count
Aaron Carter 5704
Aaron D. Price 4880
Aaron Random 92
Abby Dates 24
Abby Kamehameha 92
Hopefully that helps y'all as well
Hi there, OP here: Turns out the "Unpivot Other Columns" Power Query M solution, while valid, only works on import tables and not DirectQuery. However I could use UNPIVOT() on the SQL side to get the results how I wanted and just import the results table. This is my query
select B.Name,count(workflow_number) as Workflow_Count
from (
select Workflow_Number, Position, Name
from Workflow_Table
UNPIVOT(
Name
FOR Position in (Requester, Approver1, Approver2, Processor1, Processor2, Processor3)
) AS A
) as B
Group by Name
order by name asc
which give me output like this (Which is what I wanted):
Name WF_Count
Aaron Carter 5704
Aaron D. Price 4880
Aaron Random 92
Abby Dates 24
Abby Kamehameha 92
Hopefully that helps y'all as well
@Anonymous best way to achieve this would be to unpivot your table.
in query editor, click workflow #, right click and select "unpivot other columns"
you will get two column "attribute" and "value", rename value to "name", apply the changes.
in table visual, drop name and workflow # and change the aggregation to workflow # to count, and you will get the result.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k it worked! Idk how to mark it as solved or anything, but it got me what I wanted, thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |