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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Foxxon28
Helper I
Helper I

Dynamically Filter Based on Column

Dear reader,

 

I've been trying to tackle an issue for a while now without much succes. 

What I am trying to achieve is to dynamically filter a max month, based on sliced values.

I want to dynamically pick a MAX month, based on which value is selected in a slicer. I have created previous forum posts for this, without much luck.

 

In an effort to fix it on my own I have tried a new method, but am stick on the exectution.

 

I will give you some sample data.

 

Date (DDMMYYYY)ChannelAmountIndicator
01-01-2024A101
01-01-2024B121

01-02-2024

A51
01-02-2024B151
01-03-2024B20

0

 

I have added an [Indicator] column that checks if the [Date] of that row is higher(>) than the MAX Date from [Channel] = "A" (in this example (01-02-2024).

 

I want to create a visual level filter that returns 1, 0, based on the following conditions:

 

If NOTHING is filtered, I want to filter where [Indicator] = 1

if [Channel] CONTAINS "A", I want to filter where [Indicator] = 1

If [Channel] DOES NOT contain "A", I want to filter where [Indicator] = 1 AND 0

 

If you have any other suggestions, please let me know.

 

Kind regards,

Daniël

 

 

2 ACCEPTED SOLUTIONS
johnbasha33
Super User
Super User

@Foxxon28 

1. **Calculate Max Date for Channel A**:
- Create a measure to calculate the maximum date for Channel A. This measure will be used as a reference point for filtering.
```DAX
MaxDate_ChannelA = CALCULATE(MAX('YourTable'[Date]), 'YourTable'[Channel] = "A")
```

2. **Create Indicator Column**:
- Create an Indicator column that checks if the Date is higher than the Max Date for Channel A.
```DAX
Indicator = IF('YourTable'[Date] > [MaxDate_ChannelA], 1, 0)
```

3. **Define Visual Level Filters**:
- Create visual-level filters based on your conditions:
- If NOTHING is filtered, filter where Indicator = 1.
- If Channel CONTAINS "A", filter where Indicator = 1.
- If Channel DOES NOT contain "A", filter where Indicator = 1 AND 0.

You can use these filters to dynamically control which rows are displayed based on the slicer selections.

4. **Alternative Approach**:
- Instead of using visual-level filters, you can also create a measure that dynamically calculates the Indicator value based on slicer selections.
This measure can evaluate the slicer context and return the appropriate Indicator value accordingly.

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

View solution in original post

@Foxxon28  

FilteredValue :=
VAR ChannelContainsA = CONTAINSSTRING(SELECTEDVALUE('YourTable'[Channel]), "A")
VAR IsFiltered = NOT ISBLANK(SELECTEDVALUE('YourTable'[Channel]))

RETURN
IF(
NOT IsFiltered,
CALCULATE(SUM('YourTable'[Value]), 'YourTable'[Indicator] = 1),
IF(
ChannelContainsA,
CALCULATE(SUM('YourTable'[Value]), 'YourTable'[Indicator] = 1),
CALCULATE(SUM('YourTable'[Value]), 'YourTable'[Indicator] IN {1, 0})
)
)

View solution in original post

6 REPLIES 6
johnbasha33
Super User
Super User

@Foxxon28 

1. **Calculate Max Date for Channel A**:
- Create a measure to calculate the maximum date for Channel A. This measure will be used as a reference point for filtering.
```DAX
MaxDate_ChannelA = CALCULATE(MAX('YourTable'[Date]), 'YourTable'[Channel] = "A")
```

2. **Create Indicator Column**:
- Create an Indicator column that checks if the Date is higher than the Max Date for Channel A.
```DAX
Indicator = IF('YourTable'[Date] > [MaxDate_ChannelA], 1, 0)
```

3. **Define Visual Level Filters**:
- Create visual-level filters based on your conditions:
- If NOTHING is filtered, filter where Indicator = 1.
- If Channel CONTAINS "A", filter where Indicator = 1.
- If Channel DOES NOT contain "A", filter where Indicator = 1 AND 0.

You can use these filters to dynamically control which rows are displayed based on the slicer selections.

4. **Alternative Approach**:
- Instead of using visual-level filters, you can also create a measure that dynamically calculates the Indicator value based on slicer selections.
This measure can evaluate the slicer context and return the appropriate Indicator value accordingly.

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

@johnbasha33 could you still write an example for me :)?

Kind regards,

Daniël

@johnbasha33 Would you be so kind to give a DAX example for point 3.

And perhaps also for your alternative approach, as I've tried this, but wasn't able to achieve this.

 

Thanks! 🙂

Daniël

@Foxxon28  

FilteredValue :=
VAR ChannelContainsA = CONTAINSSTRING(SELECTEDVALUE('YourTable'[Channel]), "A")
VAR IsFiltered = NOT ISBLANK(SELECTEDVALUE('YourTable'[Channel]))

RETURN
IF(
NOT IsFiltered,
CALCULATE(SUM('YourTable'[Value]), 'YourTable'[Indicator] = 1),
IF(
ChannelContainsA,
CALCULATE(SUM('YourTable'[Value]), 'YourTable'[Indicator] = 1),
CALCULATE(SUM('YourTable'[Value]), 'YourTable'[Indicator] IN {1, 0})
)
)

amitchandak
Super User
Super User

@Foxxon28 , refer this for the latest value for each channel

 

Latest Date
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

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

@amitchandak thank you for the swift reply, however this is not what I am looking for.

The Values are used for cumulative numbers. Depending on what slicer value you select, it should dynamically calculate up untill a specific month.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors