Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

How to create Measure with filter?

I have Table with column SalesDay, ProductName, CustomerName and CustomerCity. I wanter to have one ToyotaLondonSalesCount calculated for "Toyota" and "London". I could succesfully SalesCount with Count of SalesDay with slicer CustomerName and slicer CustomerCity.

 

Now I need NissanBerlinSalesCount. Slicing is not any more good choise. I believer Measure is more flexible here. I have more filters in mind as well.

 

How to create Measure, which filters CustomerName=Toyota and CustomerCity = London. I would calculate ToyotaLondonSalesCount and then calculate ratio with NissanBerlinSalesCount. 

  • Hi Anonymous ,

    A1: Can you please share some screenshots? I can't understand what you mean. Please share the steps what you did and the results what you want.

     

    A2: Please try the formula below:

    Filter sales =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            'Table',
            'Table'[CustomerName] = "Toyota"
                && OR ( 'Table'[CustomerCity] = "London", 'Table'[CustomerCity] = "Liverpool" )
        )
    )
    

    Best Regards,

    Xue Ding

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

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks. I'm close. I have additional questions. 

       

      Question 1: I'm getting format error when using also CustomerId="1".  Possible to use Interger too?

      Question 2: Is it possible to filter if CustomerName = "Toyota" && (CustomerCity = "London" or CustomerCity = "Liverpool")

      • v-xuding-msft's avatar
        v-xuding-msft
        Community Support

        Hi Anonymous ,

        A1: Can you please share some screenshots? I can't understand what you mean. Please share the steps what you did and the results what you want.

         

        A2: Please try the formula below:

        Filter sales =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER (
                'Table',
                'Table'[CustomerName] = "Toyota"
                    && OR ( 'Table'[CustomerCity] = "London", 'Table'[CustomerCity] = "Liverpool" )
            )
        )
        

        Best Regards,

        Xue Ding

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