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. Pleas...
  • v-yanjiang-msft's avatar
    4 years ago

    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.

  • v-yanjiang-msft's avatar
    v-yanjiang-msft
    4 years ago

    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