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
rbowen
Helper III
Helper III

Create Measure With Filter Conditions

I'm trying to create a measure that uses some conditions for the final result that will included in a table visual. I have 3 previously created measures, one for Sales, one for Costs and one for Rebates. I also have a column in the data for various categories - A, B, C and D. I need to create a measure that calculates net margin for each of the categories, but when the category is A, I need to include rebates, otherwise just use Sales and Costs.  So, something like this:

 

NetMargin = IF([Category] = "A", [TotalSales] -  [TotalCosts] + [TotalRebates], [TotalSales] - [TotalCosts])

 

Where I'm running into trouble is the IF([Category] = "A" piece. I get a red underline under the [Category] part with an error message saying "Cannot find name [Category]".  I'm positive I have the syntax wrong but not sure how to correct it.  Any ideas what I'm missing?

 

Thank you.

1 ACCEPTED SOLUTION

Thank you for the reply Nono. I gave up on this approach and went a different direction by restructuring some of the data and altering some of the relationships. 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @rbowen 

 

Can you tell me if your problem is solved? If yes, please accept it as solution.

 

Regards,

Nono Chen

Anonymous
Not applicable

Hi @rbowen 

 

@Kaviraj11 Thank you very much for your prompt reply. Allow me to share some content here.

 

Measure = 
IF(
    SELECTEDVALUE('Table'[Category]) = "A", // YourTableName[Category] = "A", 
    [TotalSales] -  [TotalCosts] + [TotalRebates], 
    [TotalSales] - [TotalCosts]
)

 

vnuocmsft_0-1718247155868.png

 

Regards,

Nono Chen

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

Thank you for the reply Nono. I gave up on this approach and went a different direction by restructuring some of the data and altering some of the relationships. 

Kaviraj11
Super User
Super User

Hi,

 

Try this: 

IF(

SELECTEDVALUE([Category]) = "A", [TotalSales] -  [TotalCosts] + [TotalRebates], [TotalSales] - [TotalCosts])



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks Kaviraj11, but this doesn't work either. I still get the same red underline under [Category] with the same error message. I've also tried using the aggregator SUM but same problem. Seems to be related to using a column name with the IF statement in combination with the measures. The syntax is almost certainly incorrect but I'm not sure what the correct syntax should be. 

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.