Forum Discussion

Subash2345's avatar
Subash2345
Frequent Visitor
8 months ago
Solved

Dynamic Month Filtering

Dynamic Month Filtering Original.pbix     My requirement is in my Power BI, I have a Financial Year (July-Jun) slicer and a Month slicer.  1. If I select the Finacial Year year before current fin...
  • v-dineshya's avatar
    v-dineshya
    8 months ago

    Hi Subash2345 ,

    Please refer below updated DAX code.

     

    IsBeforeCurrentMonth =
    VAR TodayDate = TODAY()
    VAR CurrMonth = MONTH(TodayDate)
    VAR CurrYear  = YEAR(TodayDate)

    VAR CurrentFY =
        IF( CurrMonth >= 7,
            CurrYear,        
            CurrYear - 1      
        )

    VAR RowFY =
        VALUE( MID([FinancialYear], 3, 4) )  

    VAR CurrentFYMonth =
        IF(
            CurrMonth >= 7,
            CurrMonth - 6,    
            CurrMonth + 6        
        ) - 1                    

    VAR RowMonthFY = [MonthNumberFY]

    RETURN
    IF(
        RowFY < CurrentFY,      
        TRUE(),
        IF(
            RowFY = CurrentFY    
                && RowMonthFY <= CurrentFYMonth,
            TRUE(),
            FALSE()
        )
    )
     
     
    ShowMonthInSlicer =
    IF (
        SELECTEDVALUE(DummyDate[IsBeforeCurrentMonth], FALSE() ) = TRUE(),
        1,
        0
    )
     
    Please refer below output snaps.
     
    1. As you mentioned, If I select the Finacial Year year before current financial year- it should display all months.
     

     

    2.  As you mentioned , for current Financial year it should display only until completed month.  THis month is december, you mentioned to show till completed month (till november month). Please refer below snap.

     

     

     

     

    I hope this information helps. Please do let us know if you have any further queries.

     

    Regards,

    Dinesh