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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
KT9
Regular Visitor

DAX

Hi All,

I am new to the PowerBI. Using SQL Query as a base, I need to make calculated column using DAX.But having trouble to create DAX. plese help. Thanks in advance.

 

Rules for calculated column:

1. If Final = Negative, then Negative

2. If Final = positive AND type = ABCD, then display the associated value in numeric_result

3. IF Final = positive AND type = XYZ, then Positive

4. If Final = In Range, then In Range

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @KT9 ,

Looks like you're trying to create a measure instead of a calculated column.  If you use the same exact code, but as a calculated column, you shouldn't have an issue.

 

Or you can modify @KT9 's formula.

Result =
SWITCH(TRUE(),
YourTable[Final] = "Negative", "Negative",
YourTable[Final] = "Positive" && YourTable[Type] = "ABCD", max(YourTable[Numeric_Result]),
YourTable[Final] = "Positive" && YourTable[Type] = "XYZ", "Positive",
YourTable[Final] = "In Range", "In Range",
BLANK() 
)

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

3 REPLIES 3
ElliotG
Frequent Visitor

Try this

Result =
SWITCH(TRUE(),
YourTable[Final] = "Negative", "Negative",
YourTable[Final] = "Positive" && YourTable[Type] = "ABCD", YourTable[Numeric_Result],
YourTable[Final] = "Positive" && YourTable[Type] = "XYZ", "Positive",
YourTable[Final] = "In Range", "In Range",
BLANK() 
)

KT9
Regular Visitor

Hi @ElliotG , 

Thank you so much for your response. while importing the SQL data into power BI, I used import query option and wrote the sql query to filter the data and then i load it into the power BI. I tried to write the DAX formulae but it is thowing me this error. I have no idea. 

KT9_0-1705705848297.png

KT9_1-1705705891921.png

 

 

Anonymous
Not applicable

Hi @KT9 ,

Looks like you're trying to create a measure instead of a calculated column.  If you use the same exact code, but as a calculated column, you shouldn't have an issue.

 

Or you can modify @KT9 's formula.

Result =
SWITCH(TRUE(),
YourTable[Final] = "Negative", "Negative",
YourTable[Final] = "Positive" && YourTable[Type] = "ABCD", max(YourTable[Numeric_Result]),
YourTable[Final] = "Positive" && YourTable[Type] = "XYZ", "Positive",
YourTable[Final] = "In Range", "In Range",
BLANK() 
)

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.