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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
isThatAFrog
Frequent Visitor

Dynamic filter on multiple columns

Hi Community,

I have a DAX filter that is not as dynamic as I would like, but i dont know how to change it can you help?
I need to know if a move goes from a location that isnt the selected location to the selected location


Using this formula it gave me the result that I needed, but only for one location in one column

Entries = CALCULATE([CountMoves], CONTAINSSTRING( 'Mobility All'[TO loc], "Danmark") &&NOT(CONTAINSSTRING( 'Mobility All'[FROM loc], "Danmark") )
I tried this but it didnt seem to do what I wanted when adding filters multipe columns, or when reversing the formula for finding exits
Entries = CALCULATE([CountMoves], NOT(SELECTEDVALUE('Mobility All'[FROM Loc])) IN VALUES('Mobility All'[TO Loc]) ) ​


I'm attempting to create a bar chart with the + and - moves for the selected TO locations and possibly an aggregated chart as well, which does work for the not dynamic formula

Example of data:

Person IDDateFrom locFrom depFrom typeTo locTo depTo type
101-01-22DenmarkHRinternDenmarkFINStudent
201-01-22NorwayFINemployeeDenmarkCCSemployee
110-12-22DenmarkFINStudentDenmarkFINemployee
331-10-23DenmarkCCSexternalGermanyCCSemployee
302-05-24GermanyCCSemployeeGermanyFINemployee
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi All,

Firstly,  @amitchandak thanks for the solution!

And @isThatAFrog  according to my understanding,  I want to share another method. 

I think your need is to count the number of people arriving at different places and leaving to arrive at other places.

 

Entries = 
CALCULATE(
    [CountMoves],
    FILTER(
        'Mobility All',
        'Mobility All'[TO loc] = SELECTEDVALUE('Mobility All'[TO loc]) &&
        'Mobility All'[FROM loc] <> SELECTEDVALUE('Mobility All'[TO loc])
    )
)
Exits = 
CALCULATE(
    [CountMoves],
    FILTER(
        'Mobility All',
        'Mobility All'[FROM loc] = SELECTEDVALUE('Mobility All'[FROM loc]) &&
        'Mobility All'[TO loc] <> SELECTEDVALUE('Mobility All'[FROM loc])
    )
)

 

 

 

As per your example data, there are two ids for arriving elsewhere and two for leaving the region, which can be reflected in the table, I tried to use a bar chart for your requirement to create, using To loc as the x-axis and adding From Ioc to the filter can help you get the effect you want.

vxingshenmsft_0-1722301979908.png

If you have any other questions, you can check out the attachments I've provided and I hope they will help you solve the problem.

 

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

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

2 REPLIES 2
Anonymous
Not applicable

Hi All,

Firstly,  @amitchandak thanks for the solution!

And @isThatAFrog  according to my understanding,  I want to share another method. 

I think your need is to count the number of people arriving at different places and leaving to arrive at other places.

 

Entries = 
CALCULATE(
    [CountMoves],
    FILTER(
        'Mobility All',
        'Mobility All'[TO loc] = SELECTEDVALUE('Mobility All'[TO loc]) &&
        'Mobility All'[FROM loc] <> SELECTEDVALUE('Mobility All'[TO loc])
    )
)
Exits = 
CALCULATE(
    [CountMoves],
    FILTER(
        'Mobility All',
        'Mobility All'[FROM loc] = SELECTEDVALUE('Mobility All'[FROM loc]) &&
        'Mobility All'[TO loc] <> SELECTEDVALUE('Mobility All'[FROM loc])
    )
)

 

 

 

As per your example data, there are two ids for arriving elsewhere and two for leaving the region, which can be reflected in the table, I tried to use a bar chart for your requirement to create, using To loc as the x-axis and adding From Ioc to the filter can help you get the effect you want.

vxingshenmsft_0-1722301979908.png

If you have any other questions, you can check out the attachments I've provided and I hope they will help you solve the problem.

 

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

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

 

amitchandak
Super User
Super User

@isThatAFrog , Try like

 


Entries = CALCULATE([CountMoves], except(All('Mobility All'[TO Loc]),SELECTEDVALUE('Mobility All'[FROM Loc]) )) ​

or

Entries = CALCULATE([CountMoves], filter(all('Mobility All'[FROM Loc]) , 'Mobility All'[FROM Loc] in except(All('Mobility All'[TO Loc]),SELECTEDVALUE('Mobility All'[FROM Loc]) )) ​)

 

you might need to consider if you are looking for exclude scenario

Need of an Independent/disconnected Table in Power BI - Exclude: https://youtu.be/lOEW-YUrAbE

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors