Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to calculate Dynamic quarters

Hello guys I have to calculate the dynamics QUATERS  I mean now this is Sept month means Q2  so  want to show the values of Q2 and Q1 also in the next month the quarter  will change then it will show the value of Q1,Q2 and Q3 ..and then when the quarter 4 will start in it will show the values of Q1 Q2,Q3 and Q4 and then when  new year start the then it show show the value of current quarter Q1 how to do this plz help

  • Hi Anonymous 

    try this, then put the measure into visual level filter

    filterMeasure = 
    VAR _currentMonth = 7 //replace it with month(today())
    VAR _currentYear = 2022//replace it with year(today())
    VAR _quarter =
        DIVIDE ( _currentMonth, 3 )
    VAR _day =
        _quarter - QUOTIENT ( _currentMonth, 3 )
    VAR _startDate =
        IF (
            _currentMonth < 4,
            DATE ( _currentYear - 1, 1, 1 ),
            DATE ( _currentYear, 1, 1 )
        )
    VAR _endDate =
        SWITCH (
            TRUE (),
            _currentMonth < 4, DATE ( _currentYear - 1, 12, 31 ),
            _day <> 0,
                DATE ( _currentYear, INT ( _quarter ) * 3 + 1, 1 ),
            _day = 0,
                DATE ( _currentYear, ( _quarter - 1 ) * 3 + 1, 1 )
        )
    RETURN
        IF(MIN('value'[date])<_endDate&&MIN('value'[date])>=_startDate,1,0)

    2021/10

    2022/1

    2022/7

    Best Regards,

    Community Support Team _Tang

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

5 Replies