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
Anonymous
Not applicable

If statement only working when I put a new measure?

Hi,

 

So I have a calculated column where I want to categorize data based on size:

Size =
IF([SA M2]<1, "Small",
IF([SA M2]<5,"Medium",
"Large"))

 

where [SA M2] = SELECTEDVALUE(Surface_Area[SurfaceArea_m2]).

 

However, when I'm attempting to combine them, it doesn't work any more (shows everything as small).

Size 2 =
IF(SELECTEDVALUE(Surface_Area[SurfaceArea_m2])<1, "Small",
IF(SELECTEDVALUE(Surface_Area[SurfaceArea_m2])<5,"Medium",
"Large"))

 

Why would this be?

 

Any comment would be greatly appreciated

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Every Measure implies CALCULATE function automatically that preforms context transition, so...

 [SA M2] = SELECTEDVALUE( Surface_Area[SurfaceArea_m2] )

in reality, is...

 [SA M2] = CALCULATE( SELECTEDVALUE( Surface_Area[SurfaceArea_m2] ) )

therefore, your calculated column should look like that.

Size 2 = 
VAR x = CALCULATE( SELECTEDVALUE( Surface_Area[SurfaceArea_m2] ) )
RETURN 
SWITCH(
    TRUE(),
    x < 1, "Small",
    x < 5, "Medium",
    "Large"
)

this article will explain the concept of context transition.

https://www.sqlbi.com/articles/understanding-context-transition/

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

1 REPLY 1
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Every Measure implies CALCULATE function automatically that preforms context transition, so...

 [SA M2] = SELECTEDVALUE( Surface_Area[SurfaceArea_m2] )

in reality, is...

 [SA M2] = CALCULATE( SELECTEDVALUE( Surface_Area[SurfaceArea_m2] ) )

therefore, your calculated column should look like that.

Size 2 = 
VAR x = CALCULATE( SELECTEDVALUE( Surface_Area[SurfaceArea_m2] ) )
RETURN 
SWITCH(
    TRUE(),
    x < 1, "Small",
    x < 5, "Medium",
    "Large"
)

this article will explain the concept of context transition.

https://www.sqlbi.com/articles/understanding-context-transition/

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

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