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
david40ni
Helper I
Helper I

12 month prior sales showing blank

HI I tried to do a previous year lookup but it didnt work using the tutorial herre i have a calendar table based on here 

 

https://www.mssqltips.com/sqlservertip/4857/creating-a-date-dimension-table-in-power-bi/

 

And was using the caluation for the six months as a test but it came back blank I have a relation between the calendar and my date column as can be seen below.

 

daterelationship.PNG

 

You will see here I have values here for my date does date time affect these equations?.

 

dateformat.PNG

 

Basically I want to have the ability to whatever date they selection in a year filter be it 2017 2016 it should show the year previous ie if 2017 it show the total for 2016. I made sure that i marked the table as my date table but still shows blank.

 

MAT (moving annual total) = CALCULATE(
                            SUM(PBI_Sales_View[Total Price]),
	                        DATESINPERIOD('Calendar'[Date],LASTDATE('Calendar'[Date]),-6,MONTH) 
	                        )      

 

 

I no there is data for when i look at the year individually as below you will see 2018 has data  as does 2017 so when 2018 is showing it should be showing the 2017 total but its not

 

2018data.PNG

 

When I click 2017 you will see there is indead a sales total for that year

previousyeardata.PNG

4 REPLIES 4
yashasviverma
Frequent Visitor

I guess you are trying to calculate LYTD values, if so then try using This 

CALCULATE(sumx(------),
FILTER(ALLSELECTED('My Date table'),
'My Date table'[year]=MAX('My Date table'[year])-1))

david40ni
Helper I
Helper I

DATAFORAMT.PNG

 

Sorry here is some 2017 data to proove it exsits

I guess you are trying to calculate YTD values, if so then try using DATESYTD https://msdn.microsoft.com/en-us/query-bi/dax/datesytd-function-dax

 

I see its showing this

 

=CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESYTD(DateTime[DateKey]))  

But how would this no to link to the previous year 

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.