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
mwadhwani
Kudo Kingpin
Kudo Kingpin

Sameperiodlastyear function returning "Blank"

Hi Experts,

 

Fact Table: f_WS(dateid,SalesValue)
Dimension Date: d_date(dateid,date,quarter,month,year)

 

I want the SalesValue this year and last year in separate measures.
Following is the formula, I am using:

ThisYearSales=sum(SalesValue)

LastYearSales=Caluclate(sum(SalesValue),Sameperiodlastyear(d_date.date))

Following slicers are used:

Year slicer pulled from date dimension.

 

Issue:

Year has values-2014,2015,2016,2017(All years have sales value in the fact table )

Suppose I select 2016 ThisYearSales comes perfect  but LastYearSales comes (Blank) even though there is data for all the years.

 

Also, I pulled date from d_date in a slicer and tried to calculate ThisDaySales and LastDaySales using following formula:

ThisDaySales=sum(SalesValue)

LastDaySales=Caluclate(sum(SalesValue),PREVIOUSDAY(d_date.date))

I am getting PERFECT OUTPUT at Day level.

Granularity of fact table is at Day level.

 

Any help or suggestion woulb be appreciated.

 

Thanks

2 ACCEPTED SOLUTIONS
vik0810
Resolver V
Resolver V

Its because in PBI Desktop you can not mark a table as date table. So the year slicer is not reset by sameperiodlastyear. The simplest was would be to adjust your measures.

 

Previous Year Sales = CALCULATE(Measure, SAMEPERIODLASTYEAR(Dates[date]), ALL(Dates))

View solution in original post

vik0810
Resolver V
Resolver V

I downloaded your file, adjusted the meuasure and it works nowworks.png

View solution in original post

6 REPLIES 6
vik0810
Resolver V
Resolver V

I downloaded your file, adjusted the meuasure and it works nowworks.png

vik0810
Resolver V
Resolver V

Its because in PBI Desktop you can not mark a table as date table. So the year slicer is not reset by sameperiodlastyear. The simplest was would be to adjust your measures.

 

Previous Year Sales = CALCULATE(Measure, SAMEPERIODLASTYEAR(Dates[date]), ALL(Dates))

@emarc1

 

Thanks a lot...!! It indeed helped me.

🙂

@mwadhwani

 

Great!

emarc1
Advocate II
Advocate II

Your measures seem about right. You should probably refer to 'd_date'[date] rather than d_date.date. You've spelt Calculate wrong but I assume that's just because you've typed it here.

 

CALCULATE(
SUM( SalesValue ),
SAMEPERIODLASTYEAR( 'd.date'[Date] )
)

Perhaps you're filtering in a way that's hiding the previous year data. I don't think that would usually cause problems though.

 

Take screenshots of your date table and the report page or upload a pbix somewhere.

Hi @emarc1,

Thanks for the reply.

As of now I have data for the month July-2016, July-2017, Aug-2016, Aug-2017 only.

 

Please find the attached pbix file in the below link:

https://www.dropbox.com/s/n1021gcd72unjsf/POC.pbix?dl=0

 

Thanks

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.