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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rohitk1361
Regular Visitor

DAX measure If statement help

I am trying to write a dax with if statement. I want to join historical data with current year data that comes from different source, below is sample table with output and desired output.

 

in the visual i want to use scenario as a selection, so user can select scenario B, but still see historical 2023 data with scenario A, hence i added removefilter condition in first if .

 

my condition is

if (left(max(year) = "2023", calculate(sum(amt), source = ABC, removefilters(scenario)), calculate(sum(amt), source = CY)

 

ScenarioYearSourceCategoryAmtOutput shownDesired Output
A2023ABCM404040
A2023ABCN25 25
A2024ABCP70  
B2023XYZM40  
B2024CYP808080
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rohitk1361 ,

Based on my testing, Removefilters function only clear filters from the specified tables or columns. Don’t clear the slicer selected value. Please try the following methods:

1.Create the sample table.

vjiewumsft_0-1723082502971.png

2.Drag the table scena column into the slicer visual.

vjiewumsft_1-1723082514419.png

3.Create the measure to calculate the values.

Measure = 
var _selected = SELECTEDVALUE('Table Scena'[Scenario])
var _scenario = SELECTEDVALUE('Table'[Scenario])
RETURN
IF (
    _scenario = _selected,
    CALCULATE(
        SUM('Table'[Amt]),
        'Table'[Source] = "CY"
        // REMOVEFILTERS('Table Scena'[Scenario])
    ),
    IF(LEFT(MAX('Table'[Year]), 4) = "2023",
        CALCULATE(
            SUM('Table'[Amt]),
            'Table'[Source] = "ABC",
            REMOVEFILTERS('Table Scena')
        )
        
    )
)

4.Select the scenario in the slicer visual. The result is shown below.

vjiewumsft_2-1723082527264.png

You can also view the following link to learn more information.

REMOVEFILTERS function (DAX) - DAX | Microsoft Learn

Solved: DAX Measure ignore filter/slicer selection - Microsoft Fabric Community

ALL function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Wisdom Wu

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

4 REPLIES 4
rohitk1361
Regular Visitor

the logic worked earlier but now it stopped working

Anonymous
Not applicable

Hi,

Check to see if any other filters are being applied to the Tabel source data.

 

Best Regards,

Wisdom Wu

Anonymous
Not applicable

Hi @rohitk1361 ,

Based on my testing, Removefilters function only clear filters from the specified tables or columns. Don’t clear the slicer selected value. Please try the following methods:

1.Create the sample table.

vjiewumsft_0-1723082502971.png

2.Drag the table scena column into the slicer visual.

vjiewumsft_1-1723082514419.png

3.Create the measure to calculate the values.

Measure = 
var _selected = SELECTEDVALUE('Table Scena'[Scenario])
var _scenario = SELECTEDVALUE('Table'[Scenario])
RETURN
IF (
    _scenario = _selected,
    CALCULATE(
        SUM('Table'[Amt]),
        'Table'[Source] = "CY"
        // REMOVEFILTERS('Table Scena'[Scenario])
    ),
    IF(LEFT(MAX('Table'[Year]), 4) = "2023",
        CALCULATE(
            SUM('Table'[Amt]),
            'Table'[Source] = "ABC",
            REMOVEFILTERS('Table Scena')
        )
        
    )
)

4.Select the scenario in the slicer visual. The result is shown below.

vjiewumsft_2-1723082527264.png

You can also view the following link to learn more information.

REMOVEFILTERS function (DAX) - DAX | Microsoft Learn

Solved: DAX Measure ignore filter/slicer selection - Microsoft Fabric Community

ALL function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Wisdom Wu

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

lbendlin
Super User
Super User

To do this you need a disconnected table for the scenarios. Use that table to feed your slicer, and then use a measure as a visual filter for your resulting table.  You cannot implement this "OR"  logic inside a single table.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.