Forum Discussion
Creating a Transposed Table from a Calculated Table in DAX
I have a calculated table that I created to calculate scores for EACH user for EACH transaction (see table below). Currently, I had to use a calculated table to calculate these scores because the score had to be based on the user. The scores (40, 55, 98 etc) are also housed in this table but the scores were aslo labeled depending on the range they fall into. The "simplified" calculated table is as follows:
Calculated Table in DAX
| 122 Label | 133 Label | 144 Label | 155 Label | |
| [email protected] | Needs Improvement | Needs Improvement | Advanced | |
| [email protected] | Novice | Advanced | Advanced | Advanced |
| [email protected] | Needs Improvement | Advanced | Advanced |
|
| [email protected] | Advanced | Advanced | Advanced | Needs Improvement |
*there are around 2000+ users and around 30+ columns but these are the main ones I care about (score label)
*not every user is assigned to/will have a score for each transaction
Here is what I'm trying to get the visual to look like this:
Visual
| Transaction | # Advanced | # Total | % Advanced |
| 122 | 1 | 4 | 25% |
| 133 | 3 | 4 | 75% |
| 144 | 4 | 4 | 100% |
| 155 | 1 | 2 | 50% |
So essentially for EACH transaction, I want to get a total on the number of users who are labeled as "advanced" for that transaction".
Since all the calculations had to be done in DAX with a calculated table, I can't transpose this table in PowerQuery. But if there is a way I can transpose the original calculated table to make the 122 label, 133 label as columns instead or rows, the other necessary calculation to get the visual table above can be made
Happy to hear any advice!
1 Reply
- AnonymousNot applicable
Hi hellodax1
You can refer to the following two methods:
Way1: Maybe you can try to use the union() function to try to solve this problem
e.g
Table 3 = union(SELECTCOLUMNS('Table',"aaa",[122 Label]),SELECTCOLUMNS('Table',"bbb",[133 Labe]),SELECTCOLUMNS('Table',"ccc",[144 Label]))
Updating MediaPlease refer to the following links:
Solved: Union only selected columns in new table - Microsoft Power BI Community
Way 2:
You can consider completing the relevant calculations in the Excel table first, and then importing the file into Power BI and using Power Query to transpose
Best Regards,
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.