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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
skoldier24
Regular Visitor

Rolling 4 Quarters Based on Slicer Selection

Hi everyone, I've been stuggling to figure out a solution and hoping that someone in this community could point me in the right direction.

 

End Goal: Table/Matrix the displays only data for Last 4 Quarters based on slicer selection

  • I found the following post here, and was able to implement for my situation and it is mostly working: link 
    • Summary: use a disconnected date table and a flag measure to flag the last four quarters. Then, use a visual level filter and the flag measure to filter for only for quarters with "Y" as these are the last four quarters

Here is the measure I'm using to flag the last 4 quarters:

 

R4 Quarter Flag =
VAR _max =
    SELECTEDVALUE ( 'Date Copy'[Quarter Index] )
VAR _min =
    CALCULATE (
        MAX ( 'Date Copy'[Quarter Index] ),
        FILTER (
            ALL ( 'Date Copy' ),
            'Date Copy'[Quarter Index]
                = SELECTEDVALUE ( 'Date Copy'[Quarter Index] ) - 3
        )
    )
VAR TimeFrame =
    MAX ('Date'[Quarter Index])
RETURN
    IF ( TimeFrame <= _max && TimeFrame >= _min, "Y", "N" )
 

Issue: This approach doesn't seem to work when there are rows added to the matrix from other tables - ie a location table. 

  • See attached pbi file for example of the issue: pbi example - google drive 
  • The first matrix shows the R4 quarters, which is how this should work
  • The second matrix includes the location code, which causes the R4 quarter flag filter to no longer work
  • I imagine that there is something in the DAX of the R4 quarter flag that is cuasing the rows to override the column filter, however, I am not able to figure out what is causing this

It would be so appreciated if anyone is able to provide any suggestions how to make this work when there is row data as well. Thank you in advance for your help!

6 REPLIES 6
Rupak_bi
Impactful Individual
Impactful Individual

Just modify your if statement as below. 
 
RETURN
    IF ( TimeFrame <= _max && TimeFrame >= _min"Y", Blank() )
 
 


Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/
skoldier24
Regular Visitor

Does anyone else have any thoughts on this? Would love any input!

Rupak_bi
Impactful Individual
Impactful Individual

Looks like you need to use "all except( table, location) instead of all ( table). Just try and let me know. 



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

Hi Rupak, thanks for your response. I tried using ALLEXCEPT instead of ALL and I couldn't get to work on my end. I am maybe using wrong - did this work for you in the example pbi file? Thanks again, truly appreciate any help!

Rupak_bi
Impactful Individual
Impactful Individual

is it OK

 

Rupak_bi_1-1700226409767.png

 



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

That looks right! Could you please post the DAX? thank you

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors