Forum Discussion

nhaghani's avatar
nhaghani
Icon for Helper I rankHelper I
4 years ago
Solved

SAMEPERIODLASTYEAR is blank

Hello,

 

I am new to power BI

 

I am trying to get LY YTD for my sales $. I am not getting any error, but just blank data.

 

I did add below but again it just returns blank with no error. Please help!

ALL(Dates)

 

 

  • Hi nhaghani ,

    According to your description, I create a sample.

    I think you should put a date column in the visual, the SAMEPERIODLASTYEAR function should be based on an exact date.

    LY-YTD Dotcom = CALCULATE(SUM('Ulta Dotcom'[Sales]),SAMEPERIODLASTYEAR('Ulta Dotcom'[Ending-Date]))

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

     

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

  • Hi nhaghani ,

    I'm clear, you can modify the formula like this:

    LY-YTD Dotcom =
    IF (
        MAX ( 'Ulta Dotcom'[Ending-Date] )
            > DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) ),
        BLANK (),
        CALCULATE (
            SUM ( 'Ulta Dotcom'[Sales] ),
            SAMEPERIODLASTYEAR ( 'Ulta Dotcom'[Ending-Date] )
        )
    )
    

    Best Regards,
    Community Support Team _ kalyj

23 Replies

  • Hi nhaghani ,

    According to your description, I create a sample.

    I think you should put a date column in the visual, the SAMEPERIODLASTYEAR function should be based on an exact date.

    LY-YTD Dotcom = CALCULATE(SUM('Ulta Dotcom'[Sales]),SAMEPERIODLASTYEAR('Ulta Dotcom'[Ending-Date]))

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

     

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

    • nhaghani's avatar
      nhaghani
      Icon for Helper I rankHelper I

      Hello,

       

      Please see this with date below. If this column is YTD, I shouldn’t see 1/23/2021, 1/30/2021, etc…

       

      I would just want it to show 1/2/2021 at this point

       

       

       

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

        Hi nhaghani ,

        I'm sorry I'm not clear the logic of just show 1/2/2021 at this point.

        The function SAMEPERIODLASTYEAR will return a value as long as the same date of last year has a value.

        Could you please show more of your sample and expected outcome? This will help resolve your problem faster.

        Best Regards,
        Community Support Team _ kalyj

    • nhaghani's avatar
      nhaghani
      Icon for Helper I rankHelper I

      Hello,

       

      I loaded a calendar for all dates in 2021 and 2022 but I still see full 2021 instead of just up to week 6. 

       

      how do i share my .pbix file here?

      please see my sample.. my data should not go past week 6... and it is still doing the same

       

      LY YTD = IF ( MAX ('2022'[ENDING DATE].[Date]) > DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) ),CALCULATE(SUM(Sheet1[SALES $]), SAMEPERIODLASTYEAR('2022'[ENDING DATE].[Date])))

       

       

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

        Hi nhaghani ,

        This link talks about how to share a pbix file here.

        You should use date in the visual, not week.

        Best Regards,
        Community Support Team _ kalyj

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    I am getting the Blank values of Total sales of previous year. please help.

     

    • nhaghani's avatar
      nhaghani
      Icon for Helper I rankHelper I

      What is your calculation?

       

      you should use sameperiodaslastyear function 

      • Anonymous's avatar
        Anonymous
        Not applicable
        Yes, i am already using the same formula....
        AP Header Total Sales Previous Year = CALCULATE(SUM('AP Ops Header Level Report- PS'[sum(Amount Invoiced)]),SAMEPERIODLASTYEAR('AP Ops Header Level Report- PS'[[INV-P&I]]Accounting Date (Date)]))
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello,

    I have a Target column wherein i have inserted yearly target. in a same column few of my targents are in text and few in % values (Ex- 5 Days, 98%). at the time of transpose data i am getting error. there is a way to work on multiple data type in a same field or column? please help