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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
refoer
Regular Visitor

Calculating Values if cell in a different Row equals "X"

I'm trying to calculate a value in one column based on what value is present on the same row in a different colum.

 

Ie: Based on what is in column "Branch" cell 1, divide column Stock Available cell 1 by N 

 

This is what I was working with:

 

Column = if(Query1[Branch]="75 Saskatoon", Query1[StockAvailable]/294, if(Query1[Size]="25 Winnipeg, Query1[StockAvailable]/189, Query1[StockAvailable])))

 

refoer_1-1609371011867.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @refoer 

There are two mistakes in your calculated column.

First is like  

Column = 
SWITCH (
    Query1[Size] ,
    "2X4", Query1[StockAvailable] / 294,
    "2X6", Query1[StockAvailable] / 189,
    "2X8", Query1[StockAvailable] / 147,
    "2X10", Query1[StockAvailable] / 105,
    "2X12", Query1[StockAvailable] / 84,BLANK()
)
/*IF(Query1[Size] = "2X4", Query1[StockAvailable] / 294,
    IF(Query1[Size] = "2X6", Query1[StockAvailable] / 189,
    IF(Query1[Size] = "2X8", Query1[StockAvailable] / 147,
    IF(Query1[Size] = "2X10", Query1[StockAvailable] / 105,
    IF(Query1[Size] = "2X12", Query1[StockAvailable] / 84,BLANK())))))*/

Here are two ways to achieve your goal, use switch function may be better.

My sample and result is as below.

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @refoer 

There are two mistakes in your calculated column.

First is like  

Column = 
SWITCH (
    Query1[Size] ,
    "2X4", Query1[StockAvailable] / 294,
    "2X6", Query1[StockAvailable] / 189,
    "2X8", Query1[StockAvailable] / 147,
    "2X10", Query1[StockAvailable] / 105,
    "2X12", Query1[StockAvailable] / 84,BLANK()
)
/*IF(Query1[Size] = "2X4", Query1[StockAvailable] / 294,
    IF(Query1[Size] = "2X6", Query1[StockAvailable] / 189,
    IF(Query1[Size] = "2X8", Query1[StockAvailable] / 147,
    IF(Query1[Size] = "2X10", Query1[StockAvailable] / 105,
    IF(Query1[Size] = "2X12", Query1[StockAvailable] / 84,BLANK())))))*/

Here are two ways to achieve your goal, use switch function may be better.

My sample and result is as below.

1.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Rico, this was extremely helpful, thank you

Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

Column = if(Query1[Branch]="75 Saskatoon", Query1[StockAvailable]/294, if(Query1[Size]="25 Winnipeg", Query1[StockAvailable]/189, Query1[StockAvailable]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

put your text values in quotes

 

instead of  ... = 2X6   write ... = "2X6"

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