Forum Discussion

Amyries's avatar
Amyries
Helper I
1 year ago
Solved

Dynamic Sclier

Hello,

I have a table that includes the Fiscal Year (FY) field. I want to create a slicer such that when I select FY25, the data and visuals will display both FY24 and FY25. Or select FY24, display FY24 and FY23, and similarly for other years.
Data is here: (I can't attract files or links, just can capture them)

 


As a newcomer to Power BI, I would greatly appreciate your assistance. Thank you!

  • Hi Amyries 

    You will need a disconnected table (without relationship) as using column from a related table will show just what's been selected and then a measure referencing that table/column to be used as a visual filter

     

    FY Filter = 
    VAR SelectedFY =
        MAX ( FY[FY Number] )
    VAR _FY = {
        "FY" & SelectedFY - 1,
        "FY" & SelectedFY
    }
    RETURN
        CALCULATE (
            COUNTROWS ( 'Date' ),
            KEEPFILTERS ( TREATAS ( _FY, 'Date'[Fiscal Year] ) )
        )
    

    Please see the attached sample pbix.

5 Replies

  • Hi Amyries 

    You will need a disconnected table (without relationship) as using column from a related table will show just what's been selected and then a measure referencing that table/column to be used as a visual filter

     

    FY Filter = 
    VAR SelectedFY =
        MAX ( FY[FY Number] )
    VAR _FY = {
        "FY" & SelectedFY - 1,
        "FY" & SelectedFY
    }
    RETURN
        CALCULATE (
            COUNTROWS ( 'Date' ),
            KEEPFILTERS ( TREATAS ( _FY, 'Date'[Fiscal Year] ) )
        )
    

    Please see the attached sample pbix.

  • Thank you, but I Select FY24 as the visual just show data for FY23