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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Jeni2608
Frequent Visitor

derived column based on nested case statements across multiple columns from multiple dim tables

how to convert the below SQL in Power BI report, this is the report level derived column .

 

 

(CASE WHEN Dim1.col1 like '%OT%' THEN (case when Dim2.col2 = 'NOT APPLICABLE' OR Dim2.col3 IS NULL THEN Dim3.col1 ELSE Dim2.col2 END) ELSE (Dim1.col1 IS NULL OR Dim3.col1 = 'NOT APPLICABLE' THEN Dim2.col2 ELSE Dim3.col1 END) END)

2 REPLIES 2
VahidDM
Super User
Super User

Hi @Jeni2608 

 

It would be better if you share more info about your model and relations between tables, BTW, 

In Power BI, you can create a calculated column using the DAX formula to achieve similar result of the above SQL code. The DAX formula would be:

 

IF( CONTAINS(Dim1[col1], "OT"), IF( OR(Dim2[col2] = "NOT APPLICABLE", ISBLANK(Dim2[col3])), Dim3[col1], Dim2[col2] ), IF( OR(ISBLANK(Dim1[col1]), Dim3[col1] = "NOT APPLICABLE"), Dim2[col2], Dim3[col1] ) )

 

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

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

Thanks for the quick reply, i will share the model soon, BTW - on which table should i create this calculated column out of the three dimension tables involved here.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.