Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nhaghani
Helper I
Helper I

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)

 

nhaghani_0-1641413501644.png

 

2 ACCEPTED SOLUTIONS
v-yanjiang-msft
Community Support
Community Support

Hi @nhaghani ,

According to your description, I create a sample.

vkalyjmsft_0-1642496706001.png

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]))

vkalyjmsft_0-1641801823412.png

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.

View solution in original post

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

View solution in original post

23 REPLIES 23
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

Anonymous
Not applicable

Vishal_Chauhan_0-1644296859014.png

Vishal_Chauhan_1-1644296894077.pngVishal_Chauhan_2-1644296943766.png

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

What is your calculation?

 

you should use sameperiodaslastyear function 

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)]))

Hi,

Create a Calendar Table with a relationship from the Accounting Date column of your Table to the Date column of the Calendar Table.  In the Calendar Table, write calculated column formulas to extract Year, Month Name and Month number.  Sort the Month name column by the Month number.  To your visual, drag Year and Month name from the Calendar Table.  Write these measures

Total = SUM('AP Ops Header Level Report- PS'[sum(Amount Invoiced)])

Total in same period last year = calculate([Total],sameperiodlastyear(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yanjiang-msft
Community Support
Community Support

Hi @nhaghani ,

According to your description, I create a sample.

vkalyjmsft_0-1642496706001.png

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]))

vkalyjmsft_0-1641801823412.png

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.

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])))

 

nhaghani_0-1644339781458.png

 

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

 

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

 

 

nhaghani_0-1642606270991.png

 

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

I expect the data to show last year, Year to Date, meaning I dont want to see anything past today's date for last year. For today i would want to see data up to 1/20/2021 and nothing passed that date. So I dont want to see Feb, March, April, May, June etc for 2021. Just Last Year - Year To Date. 

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

I changed the sign and it looks like I am getting there, but it is showing the total for the month of Jan 2021 in stead of just up to today LY... Any suggestions to get it to "Today LY"?

nhaghani_2-1642791839338.png

 

Hi @nhaghani ,

LY-YTD Dotcom show value for last year of the Date column, you don't want to see anything past today's date for last year, you mean you don't want to see the part framed by the red line, as shown in Case 1 or Case2.

Case1

vkalyjmsft_0-1642990915439.png

Case2

vkalyjmsft_2-1642991155375.png

My previous formula was for case 2, from your screenshot it looks like this is the case.

If you are now expecting case 1, you should modify the formula like this:

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

It should be ">", not "<" in the formula, because you don't want see data past today, and the date column should be a date containing year month day.

 

Best Regards,
Community Support Team _ kalyj

 

Hello, I tried above and its not returning ANY data...

 

LY YTD = IF (MAX('2022'[ENDING DATE].[Date])>TODAY(),BLANK(),CALCULATE(SUM(Sheet1[SALES]), SAMEPERIODLASTYEAR('2022'[ENDING DATE].[Date])))
 
the Ending Date is only on Saturdays, wonderinf if that is causing the issue?

hello,

 

I used the query you sent, its not failing, but its not returning any data... do I need to change anything with the date part? 

nhaghani_0-1642791018666.png

 

nhaghani_1-1642791078668.png

 

 

Also I wanted to let you know, my "Ending Date".Date is only showing Saturday's date for Last year and today...  Could this be causing the issue for data not to show up?

nhaghani_0-1643833359928.png

 

this is my calendar:

nhaghani_0-1643835933863.png

 

I created a calendar with all dates for 2021 and 2022.

Below on the left is what I would like to see, but I am currently getting what is on the right. Now my YTD is repeating for future weeks...

 

Here are my calculations:

 

YTD =TOTALYTD(SUM('Sheet1'[SALES $]), '2022'[ENDING DATE])

 

LY YTD = IF ( MAX ('2022'[ENDING DATE]) > TODAY(), BLANK (),CALCULATE(SUM(Sheet1[SALES $]), SAMEPERIODLASTYEAR('2022'[ENDING DATE])))
 

nhaghani_0-1643847254075.png

 

Hi @nhaghani ,

In the visual, you should put the date column, not the WK, also, if you only has date in saturday, the SAMEPERIODLASTYEAR will return value only when it has a value in the date column in the same date last year.

For example, for date 2022/2/8, if 2021/2/8 isn't in your date column, the LY-YTD will not return value.

Best Regards,
Community Support Team _ kalyj

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.