Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Previous Quarter

How can I calculate Previous Quarter like I've calculated the current month using the below calculation.

 

I want a measure to show the values for the previous quarter.

 

I think if I get something like, IsLastQuarter = True/False hen my issue will be resolved.

 

IsCurrentMonth =
    IF (
        YEAR ( 'D_DATE'[FULL_DATE] ) = YEAR ( TODAY () )
            && MONTH ( 'D_DATE'[FULL_DATE] ) = MONTH ( TODAY () ),
        "Yes",
        "No"
    )
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    Please check if this is the result you want:

    IsCurrentQuarter = 
    VAR _CUR_QUARTER =
        QUARTER ( TODAY() )
    VAR _CUR_YEAR =
        YEAR ( TODAY() )
    VAR _RESULT =
        SWITCH (
            TRUE (),
            _CUR_QUARTER <> 1
                && YEAR ( 'D_DATE'[FULL_DATE] ) = _CUR_YEAR
                && QUARTER ( 'D_DATE'[FULL_DATE] ) = _CUR_QUARTER - 1, "Yes",
            _CUR_QUARTER = 1
                && YEAR ( 'D_DATE'[FULL_DATE] ) = _CUR_YEAR - 1
                && QUARTER ( 'D_DATE'[FULL_DATE] ) = 4, "Yes",
            "No"
        )
    RETURN
        _RESULT

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

2 Replies

  • Anonymous , Calculations based on Today

     

    QTD Today =
    var _max = today()
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    QTD Yesterday =
    var _max = today()-1
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    LQTD Today =
    var _max = Date(year(today()), Month(Today())-3, day(today()))
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    LYQTD Today =
    var _max = Date(year(today())-1, Month(Today()), day(today()))
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    This Qtr Today =
    var _today = today()
    var _max = eomonth(_today, if( mod(Month(_today),3) =0,0,3-mod(Month(_today),3)))
    var _min = eomonth(_max,-3)+1
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    Last Qtr Today =
    var _today = today()
    var _max = eomonth(_today, -1*if( mod(Month(_today),3) =0,3,mod(Month(_today),3)))
    var _min = eomonth(_max,-3)+1
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

    Same Qtr Last Year Today =
    var _today = today()
    var _max = eomonth(eomonth(_today, if( mod(Month(_today),3) =0,0,3-mod(Month(_today),3))),-12)
    var _min = eomonth(_max,-3)+1
    return
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

     

     

    https://medium.com/chandakamit/cheat-sheet-power-bi-time-intelligence-formulas-using-today-654f26e27304

     

    Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
    Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Please check if this is the result you want:

    IsCurrentQuarter = 
    VAR _CUR_QUARTER =
        QUARTER ( TODAY() )
    VAR _CUR_YEAR =
        YEAR ( TODAY() )
    VAR _RESULT =
        SWITCH (
            TRUE (),
            _CUR_QUARTER <> 1
                && YEAR ( 'D_DATE'[FULL_DATE] ) = _CUR_YEAR
                && QUARTER ( 'D_DATE'[FULL_DATE] ) = _CUR_QUARTER - 1, "Yes",
            _CUR_QUARTER = 1
                && YEAR ( 'D_DATE'[FULL_DATE] ) = _CUR_YEAR - 1
                && QUARTER ( 'D_DATE'[FULL_DATE] ) = 4, "Yes",
            "No"
        )
    RETURN
        _RESULT

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data