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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
anonymous188
Regular Visitor

different calculation depending on ID

Hi,

 

I have the following made-up tables:

 

Employee IDProduct Sold
111Banana
112Apple
112Kiwi
113Apple
113Kiwi
113Mango

 

Employee IDRole ID
1111
1121
1132
1141
1152

 

I'm trying to count the number of distinct products each employee has sold, but then multiply the number sold by 3 if their Role ID is 2 and by 1 if their Role ID is 1.  I'd like to create a chart within Power Bi with this information which would look like the following:

 

Employee IDBonus
1111
1122
1139
1140
1150

 

Thanks in advance for any help with this problem. 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

add a measure 

 

Counts = 
var cnt = Count(Table1[Product Sold])
return cnt * if(MAX(Table2[Role ID]) = 2,3, 1) 

change the table name/column name as it fit in your data model.



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.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

add a measure 

 

Counts = 
var cnt = Count(Table1[Product Sold])
return cnt * if(MAX(Table2[Role ID]) = 2,3, 1) 

change the table name/column name as it fit in your data model.



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.

This solution worked for display purposes, but the SUM is incorrect somehow. Rather than applying the logic based on the Role ID, the resulting value is the sum of every count multiplied by 3.

 

In other words, this is the resulting sum:

Employee IDCounts
1111
1122
1139
Total18

 

Any idea what a fix might be?

change max to sum and see



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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors