Forum Discussion

rbhattacharya's avatar
5 years ago
Solved

Help for DAX For End Of Quarter

Hello,   Please refer to the attached screenshot which is a date filter in my report. Based on the current selected month (January), I need to derive some calculated value for the end of quarter mo...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi rbhattacharya ,

     

    According to my understanding, you want to get  the calculation of the last month of quarter based on the selected month in slicer.

     

    You need to create a new table for slicer like this:

     

    ForSlicer =
    DISTINCT (
        SELECTCOLUMNS (
            CALENDAR ( MIN ( 'Original Table'[Date] ), MAX ( 'Original Table'[Date] ) ),
            "Year", YEAR ( [Date] ),
            "Month", FORMAT ( [Date], "MMMM" ),
            "MonthNo", MONTH ( [Date] ),
            "Quarter", QUARTER ( [Date] )
        )
    )
    

     

    Then try the following formula:

     

    Measure =
    VAR _lastMonthofQuarter =
        MAXX (
            FILTER (
                ALL ( 'ForSlicer' ),
                'ForSlicer'[Quarter] = MAX ( 'ForSlicer'[Quarter] )
                    && 'ForSlicer'[Year] = MAX ( 'ForSlicer'[Year] )
            ),
            [MonthNo]
        )
    RETURN
        CALCULATE (
            SUM ( 'Original Table'[Value] ),
            FILTER (
                'Original Table',
                'Original Table'[Date].[MonthNo] = _lastMonthofQuarter
                    && 'Original Table'[Date].[Year] = MAX ( 'ForSlicer'[Year] )
            )
        )
    

     

    The final output is shown below:

     

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