Forum Discussion

Erik70's avatar
Erik70
Frequent Visitor
3 years ago
Solved

same day last year

Hi,

im struggling to get this "same day last year" to work.

i have ordersum and if i set filters manually it will show the correct value but i want it to automatically look at todays date and show me today one year ago for comparison.

 

the "ordersumma" column and the "upplagd" column are all in the same table.

 

 

any ideas how to get this to work is much appreciated.

 

//:Erik

 

 

 

 

  • Hi Erik70 ,

     

    According to your description, I created a sample and here is my solution.

    Create a measure.

    measure =
    SUMX (
        FILTER (
            ALL ( 'PBI_kundorder' ),
            [Upplagd] = EDATE ( MAX ( 'PBI_kundorder'[Upplagd] ), -12 )
        ),
        [Ordersumma]
    )
    

    Final output:

     

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ xiaosun

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

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Erik70 Try:

     

    Measure =
      VAR __Today = TODAY()
      VAR __1YearAgo = DATE(YEAR(__Today)-1,MONTH(__Today),DAY(__Today))
    RETURN
      SUMX(FILTER(ALL('PBI_kundorder'),[Upplagd] = __1YearAgo),[Ordersumma])

     

    • Erik70's avatar
      Erik70
      Frequent Visitor

      Hi, thanks for your effort but neither of the suggested fixes seems to work, no errors just blank renamed it to lastyear! wondering if this has to do with that the date includes a timestamp also? 

       

    • Erik70's avatar
      Erik70
      Frequent Visitor

      Hi, thanks for your effort but neither of the suggested fixes seems to work, no errors just blank (renamed it to lastyear2)! wondering if this has to do with that the date includes a timestamp also? 

  • v-xiaosun-msft's avatar
    v-xiaosun-msft
    Icon for Community Support rankCommunity Support

    Hi Erik70 ,

     

    According to your description, I created a sample and here is my solution.

    Create a measure.

    measure =
    SUMX (
        FILTER (
            ALL ( 'PBI_kundorder' ),
            [Upplagd] = EDATE ( MAX ( 'PBI_kundorder'[Upplagd] ), -12 )
        ),
        [Ordersumma]
    )
    

    Final output:

     

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ xiaosun

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