cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rswami_4
Helper I
Helper I

Change Filter Sequence in Power BI

I have a table that looks like this:

 

MyTable  
MyColumn1MyColumn2MyColumn3
10-AugValue 1X
10-AugValue 2 
10-AugValue 1X
11-AugValue 1 
11-AugValue 2X
12-AugValue 1X

 

I have a slicer on MyColumn2 (contains two values - Value 1 and Value 2)

 

I have a calculated column that looks like:

 

MyColumn 4 = COUNTROWS(
FILTER('MyTable' ,
 'MyTable'[MyColumn3] = "X" && 'MyTable'[MyColumn1] <= earlier('MyTable'[MyColumn1])
)
)

 

I need the slicer filter (on MyColumn2) to apply before the DAX Filter (MyColumn3) applies.  Otherwise the results are very different.  How can I make it happen?

1 ACCEPTED SOLUTION

Eric,

 

I figured out this issue though the solution was surprising to me.  First of all I was trying to create and use a calculated column like this instead (which is a variation of the previous one):

 

MyColumn 4 = CALCULATE(COUNTROWS(
FILTER(ALLEXCEPT('MyTable' , 'MyTable'[MyColumn2]
 'MyTable'[MyColumn3] = "X" && 'MyTable'[MyColumn1] <= earlier('MyTable'[MyColumn1])
)
)

 

That did not work.  However, it worked when I created and used a calculate measure instead like this:

 

MyMeasure 4 = CALCULATE(COUNTROWS(
FILTER(ALLEXCEPT('MyTable' , 'MyTable'[MyColumn2]
 'MyTable'[MyColumn3] = "X" && 'MyTable'[MyColumn1] <= MAX('MyTable'[MyColumn1])
)
)

 

Still cannot understand why a measure seems to have the filters applied in a different sequence from a column.  Basically, I was trying to use a slicer to display filtered cummulate values in a bar chart.

 

Any idea when other forms of slicers will be available in Power BI ( like drop down menu, multiple selection, radio button, etc)?  Will really help make more versatile slicing and dicing of visualizations

 

 

View solution in original post

2 REPLIES 2
Eric_Zhang
Microsoft
Microsoft

@rswami_4

 

I guess that you're looking for something like

 

MyColumn 4 =
COUNTROWS (
    FILTER (
        'MyTable',
        'MyTable'[MyColumn3] = "X"
            && 'MyTable'[MyColumn1] <= EARLIER ( 'MyTable'[MyColumn1] )
            && MyTable[MyColumn2] = EARLIER ( 'MyTable'[MyColumn2] )
    )
)

 

Capture.PNG

 

If it is not the case, please be more specific on the expected output.

Eric,

 

I figured out this issue though the solution was surprising to me.  First of all I was trying to create and use a calculated column like this instead (which is a variation of the previous one):

 

MyColumn 4 = CALCULATE(COUNTROWS(
FILTER(ALLEXCEPT('MyTable' , 'MyTable'[MyColumn2]
 'MyTable'[MyColumn3] = "X" && 'MyTable'[MyColumn1] <= earlier('MyTable'[MyColumn1])
)
)

 

That did not work.  However, it worked when I created and used a calculate measure instead like this:

 

MyMeasure 4 = CALCULATE(COUNTROWS(
FILTER(ALLEXCEPT('MyTable' , 'MyTable'[MyColumn2]
 'MyTable'[MyColumn3] = "X" && 'MyTable'[MyColumn1] <= MAX('MyTable'[MyColumn1])
)
)

 

Still cannot understand why a measure seems to have the filters applied in a different sequence from a column.  Basically, I was trying to use a slicer to display filtered cummulate values in a bar chart.

 

Any idea when other forms of slicers will be available in Power BI ( like drop down menu, multiple selection, radio button, etc)?  Will really help make more versatile slicing and dicing of visualizations

 

 

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!