Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

WHERE statement in power bi

Does power bi have a where statement like in SQL? 

Example: 

sum_C =sum(target_values) where product= "C";

I want to put a condition in my visual where athe sum of target values is returned but only for product C and not for anything else. I dont want to use the already given filter tool in power bi as i need to find the overall sum of 3 products in the end (sum_a+sum_b+sum_C) 

 

  • Hi Anonymous 

     

    Try this:

     

    Measure = Calculate ( SUM ( Table[target_values] ), Filter( Table , Table[product] = "C" ) )

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/

     

     

3 Replies

  • CALCULATE(SUM(target_values), Product = "C")

     

    The calculate is an expression modifier. This should accept your criteria.

  • Hi Anonymous 

     

    Try this:

     

    Measure = Calculate ( SUM ( Table[target_values] ), Filter( Table , Table[product] = "C" ) )

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      This worked! Thank you 🙂