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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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