Skip to main content

How to Filter Multiple Values in Same Column using DAX

When you working with Tabular modeling projects you may encounter this problem. How we can filter multiple cell values that are in the same column using DAX for creating measure.

Scenario:

Let's say you have a table with Sales data as below. Which contains Product information and sales amounts.


Assume, you have a requirement to create a Calculated Measure to filter only Clothing and Accessories. Of course, you can do this using a filter pane as shown below.

Remember this requirement is not to have multiple predicates with different columns but, in the same column.

Solution:

We can write a DAX code like this to solve this problem. In here I create a Calculated Measure called Other Products which filters all the records in Sales query for Category Accessories and Clothing.

EVALUATE
CALCULATE (
    SUM ( Sales[Sales Amount] ),
    FILTER ( Sales, Sales[Category] IN { "Accessories""Clothing" } )
)


You can achieve the same results like you had earlier through this.



Conclusion:


This is an alternative way of filtering multiple predicate logics in the same column using DAX. Sometimes you may find this as a very useful method especially if you are working with Finance related calculations, Chart of Account. Let us know what you think about this and would like to hear your feedback. 

Comments

Post a Comment

Popular posts from this blog

How to Add My Power BI Report in My PowerPoint Presentation?

Had a great week after conducting two-day sessions on Data Warehousing and How to do Business Intelligence with Microsoft Power BI . During the sessions, I got an interesting question from the audience. The question was “how its possible to show the Power BI report or visuals in my Powerpoint slides, at the same time the data need to be up-to-date same as in report”. I love these sort of questions and find solutions because these are real-world problems they have. I thought to write a simple post to address that problem, and in this post, I explain how to achieve it. Pre-requisites You have already Power BI report created and published to the Power BI service. If you missed how to do it read this blog . If your source is a file like Excel or CSV the deployment is even simple. You don't want to worry about to configure the gateway and you can simply click Publish and publish your report. Steps to Follow Open the MS PowerPoint and go to Insert tab and My-Addins It will ...

Get Started with Azure Machine Learning

Azure Machine Learning is a Microsoft cloud solution which allow us to do end-to-end experiments using the samples, experiments provided. Further, it allows us to write custom algorithms using popular data science languages like R and Python.  Lets start to create preview account on Azure and create Azure Machine Learning Experiment workspace. Microsoft gives 30 days trial period for free to do experiments on Azure. You can start to create an Azure account from here. When you sign-up you might need to provide credit card details that only for validate the user. As far as I know we only need to pay if we are going to upgrade the free subscription for Pay-as-you-go model. Lets start to create a machine learning experimentation. For that click on left down below "More services" and from the search bar, type "Machine Learning". Then click the Machine Learning Experimentation in order to create new environment. Then it will open new blades to provide d...

How to Resume Azure SQL Serverless Database Manually?

Problem It was a horrible experience with a busy day. Suddenly the Developer Database, presumably Azure SQL Serverless Database went off. In another word, it was in Auto-pause mode.  When I search through the internet, I couldn't find any reliable method of turn it back to accessible or resume mode. According to the documentation , If I login to the database then it should be turned it back, but it is not the case. I tried with both Management Studio and Azure Data Studio those options were not in my favor. Solution Unfortunately, the solution is pending. Unless you have to trigger manually by doing one of the tasks was in the list I've referenced above. I found that this feature is started to develop, according to the Microsoft Azure forum . But, that is not helpful to get sorted my issue today. Workaround  Maybe if you are an Application developer you might not get this issue. Perhaps if you invoke some function which hit to the database, this problem wi...