Forum Discussion

Yoshimitsu411's avatar
Yoshimitsu411
Icon for Resolver I rankResolver I
6 years ago
Solved

Calculate YTD using Short Month Name

Hello   I need to calculate the YTD value excluding the current month. I have the following information in a data table with a Month column. I added the Month_Number column using Switch. I now need...
  • Ashish_Mathur's avatar
    Ashish_Mathur
    6 years ago

    Hi,

    You may download my PBI file from here.

    Hope this helps.

  • Yoshimitsu411's avatar
    Yoshimitsu411
    6 years ago

    thanks Ashish_Mathur danextian amitchandak stretcharm for all your help.

     

    I was able to solve this using Ashish_Mathur solution.

     

    I also found a similar solution here which also worked - https://community.powerbi.com/t5/Desktop/TotalYTD-to-Last-Month/m-p/692437

     

    Correct Formula = 
    VAR pre =
        CALCULATE (
            MAX ( 'CalendarAuto'[Date] ),
            FILTER ( 'CalendarAuto', DATEDIFF ( 'CalendarAuto'[Date], TODAY (), MONTH ) = 1 )
        )
        RETURN
            CALCULATE(
                SUM(Sheet1[EAC]),
                FILTER(
                    Sheet1,
                    YEAR(Sheet1[Custom Date]) = YEAR(pre)
                    && Sheet1[Custom Date] <= pre
                )
            )

     

    The idea of using a separate Calendar table is a good one and one that I will use in the future I'm sure. Thanks danextian for the tip.

     

    Thanks again.

     

    Yoshi