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

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

Reply
CalvinL
Helper II
Helper II

How to calculate two columns based on another?

Hi all,

 

Looking to calculate two values based off of another column.

 

Example:

I want to calculate the sales of shop1 and shop2 but only if it is in New York.

IDCityShop1SalesShop2Sales

1

New York4030
2Chicago2035
3New York5010
4Chicago1010

 

So the result should be in a new column:

TotalNewYorkSales

70

0

60

0

 

Any help appreciated.

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

I encourage you to unpivot your data, but, if not, you can try use this measure expression

 

NY Sales = CALCULATE(SUMX(Table, Table[Shop1Sales] + Table[Shop2Sales]), KEEPFILTERS(Table[City] = "New York")) + 0

 

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

2 REPLIES 2
amitchandak
Super User
Super User

@CalvinL , try a measure like

TotalNewYorkSales = sumx(filter(Table, Table[City] = "New York"), Table[Shop1Sales]+ Table[Shop2Sales])+0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
mahoneypat
Microsoft Employee
Microsoft Employee

I encourage you to unpivot your data, but, if not, you can try use this measure expression

 

NY Sales = CALCULATE(SUMX(Table, Table[Shop1Sales] + Table[Shop2Sales]), KEEPFILTERS(Table[City] = "New York")) + 0

 

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


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.