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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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. 

1 ACCEPTED SOLUTION

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" )
    )
)

1.PNG

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.

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.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Try

 

Filter sales =calculate(sum(sales[day sales]),filter(customer, CustomerName="Toyota" && CustomerCity = "London")

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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")

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" )
    )
)

1.PNG

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.

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.