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

Creating a calculated column based on several conditions

Capture11.PNG

I have the table above. I need to add a column based on the Trade and StageOrder columns.

 

For example, if the trade is plumbing and the stageorder is between 2 and 6 then = ground

and if stageorder is between 7 and 12 then = topout

and if stageorder is 13 or higher then = trim

 

How can I write code to achieve this

3 REPLIES 3
Anonymous
Not applicable

Thank you for your response.

 

Capture12.PNG

Why is the column not being recognized unless I use an aggregate? My data source is an excel workbook

 

Thank you

 

 

 

 

Hi @Anonymous ,

Because the column "builderStageOrder" is not in the same table with the calculated column, so you can't quote it directly. Have you got the expected result by using an aggregate? If not, can you illustrate the relationship (cardinality and direction) of the "HousesLastMilestone" table and "Builder Stages" table?

Best Regards,
Community Support Team _ kalyj

Pragati11
Super User
Super User

Hi @ ,

 

You acn write a DAX someting as below for the calculated column:

newCalc =
IF (
    yourtable[Trade] = "Plumbing"
        && ( yourtable[StageOrder] >= 2
        && yourtable[StageOrder] <= 6 ),
    "ground",
    IF (
        yourtable[StageOrder] >= 7
            && yourtable[StageOrder] <= 12,
        "topout",
        IF ( yourtable[StageOrder] >= 13, "trim", "N/A" )
    )
)

I have given a else condition as last one as N/A. You can modify it based on your requirement.

Replace yourtablename in above DAX with your actual table name.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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.

Top Solution Authors