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

Nested IF or Filter

Multiplicaiton:  Dax code with filters, how to write code for a new column?

 

test = Weight1 * weight2 * Adj  ................filter by customer, filter by material, filter by channel (and maybe another filter as well) 

 

or IF statement if that would work better?  Unless there is something better, I am still learning all these DAX codes.

 

Thank you!

1 ACCEPTED SOLUTION

Hi @yaya1974 - can you try below one.

FilteredProduct =
IF (
    AND (
        AND (
            'iftest'[CustomerID] = "CustomerA",  
            'iftest'[MaterialID] = "MaterialX"
        ),
        'iftest'[ChannelID] = "ChannelY"
    ),
    'iftest'[Weight1] * 'iftest'[Weight2] * 'iftest'[Adj],
    BLANK()  -- Returns blank if the filter criteria are not met
)

rajendraongole1_0-1722882987058.png

 

Hope it works.





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

Proud to be a Super User!





View solution in original post

4 REPLIES 4
rajendraongole1
Super User
Super User

Hi @yaya1974 - Create calculated column using if and in your table


FilteredProduct =
IF (
AND (
'SalesData'[CustomerID] = "CustomerA", -- Replace with your filter criteria
'SalesData'[MaterialID] = "MaterialX", -- Replace with your filter criteria
'SalesData'[ChannelID] = "ChannelY" -- Replace with your filter criteria
),
'SalesData'[Weight1] * 'SalesData'[Weight2] * 'SalesData'[Adj],
BLANK() -- Returns blank if the filter criteria are not met
)

for better you can also try with switch statement

Hope it helps





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

Proud to be a Super User!





Thank you!   As soon as I add the coma after the Material I get syntax error.  any idea why?   

Also I am not familar with Switch.

Hi @yaya1974 - can you try below one.

FilteredProduct =
IF (
    AND (
        AND (
            'iftest'[CustomerID] = "CustomerA",  
            'iftest'[MaterialID] = "MaterialX"
        ),
        'iftest'[ChannelID] = "ChannelY"
    ),
    'iftest'[Weight1] * 'iftest'[Weight2] * 'iftest'[Adj],
    BLANK()  -- Returns blank if the filter criteria are not met
)

rajendraongole1_0-1722882987058.png

 

Hope it works.





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

Proud to be a Super User!





Thank you!!

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.