Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
r_ramillien
Regular Visitor

Sum values per user where user can be in multiple column

Dear Power BI community,

 

I'm facing an issue where I have simple table with columns "amount" and "user1", "user2", "user3", etc.

The same user can be in any of this columns.

I would like to have a visual with the total of each user.

 

So for instance, if my source table contains:

25 userA userB userC

50 userB null null

75 userA UserB

 

I would like a visual like this:

userA 100

userB 150

userC 25

 

Do you think it is possible with DAX, or with prior transformation in powerQuery ?


Thanks for all your kind responses 😁

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

You could do it with DAX and the SEARCH function but it is much better to unpivot your data in the query editor.  Highlight the Amount column, right click and choose unpivot other columns.  Do any other clean up that is necessary and then you should have two columns with Users and Amounts you can easily sum by user in your visuals.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

StefanoGrimaldi
Resident Rockstar
Resident Rockstar

well them you need to tranform the data, thats not a friendly table for dataset, so go over to your power bi query editor, elect all columns that are not the users columns xD and use the unpivot function of the software to make all user be in one unique column you will have something like this: 

StefanoGrimaldi_0-1610931810718.png

now you go over to your report section with that tranformed table and just put those 2 fields on a normal table visual you will get this result: 

StefanoGrimaldi_1-1610931904052.png

sso basically the missinsg and important step here its your table tranformation for a nice clean table, 

if this solved your question give some kudos and mark it as solution for others to find it more easily.





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
StefanoGrimaldi
Resident Rockstar
Resident Rockstar

well them you need to tranform the data, thats not a friendly table for dataset, so go over to your power bi query editor, elect all columns that are not the users columns xD and use the unpivot function of the software to make all user be in one unique column you will have something like this: 

StefanoGrimaldi_0-1610931810718.png

now you go over to your report section with that tranformed table and just put those 2 fields on a normal table visual you will get this result: 

StefanoGrimaldi_1-1610931904052.png

sso basically the missinsg and important step here its your table tranformation for a nice clean table, 

if this solved your question give some kudos and mark it as solution for others to find it more easily.





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Thank you for your help,

 

I made some tests and it works great !

mahoneypat
Employee
Employee

You could do it with DAX and the SEARCH function but it is much better to unpivot your data in the query editor.  Highlight the Amount column, right click and choose unpivot other columns.  Do any other clean up that is necessary and then you should have two columns with Users and Amounts you can easily sum by user in your visuals.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


StefanoGrimaldi
Resident Rockstar
Resident Rockstar

hey,

question here, you have a column per each user? or 2 columns: amount, user id? 





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Hello,
I have a column for the amount and a defined number of columns for users (lets say 3 columns for example).
In each of these 3 columns, I have any user name.

 

For example:

Amount | user1 | user2 | user3

25          | userA |           | userB

4            | userB | userA |

52          | userX | userP | userB

 

In the real table, I have 11 columns for users and hundreds of differents user.

 

Thanks Stefano for you help,

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors