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
tlehner926
Frequent Visitor

Last Year vs. YTD on a daily basis

Hi everyone,

 

Think I screwed something within my measures and I'm not able to fix it. I follow tutorials like https://community.powerbi.com/t5/Community-Blog/Dynamically-comparing-current-totals-to-last-year-to... to compare YTD vs LY and I'm nearly there but on the last meters I struggle.

 

Using my measures I get the following visual and please see within the graphics my issue. My year to date measure works flawless, my "last year" measure is showing me the cummulated data till end of the current month from last year.

 

2018-04-03 08_31_48-Testcockpit - Power BI Desktop.png

 

I've created as recommended a dedicated calendar table using this expression and all my tables are in relationship to this calender:

Kalender =
GENERATE (
CALENDAR( DATE( 2007;1;1 ); NOW());
VAR currentDay = [Date]
VAR day = DAY( currentDay )
VAR month = MONTH ( currentDay )
VAR year = YEAR ( currentDay )
RETURN ROW (
"day"; day;
"month"; month;
"year"; year )
)

 

Here are my measures

Total Units LY = CALCULATE([Quantity Units]; SAMEPERIODLASTYEAR(Kalender[Date]))

 

Quantity Surgical Guides YTD =
IF(
ISFILTERED('Kalender'[Date]);
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column.");
TOTALYTD([Quantity Units]; 'Kalender'[Date].[Date])
)

 

 

Can anyone please point me into the right direction? Any help is greatly appreciated,

Tobias

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Your measures should be:

 

Total units YTD = CALCULATE(SUM(Data[Units sold]),DATESYTD(Calendar[Date],"31/12"))

Total units YTD (Last year) = CALCULATE([Total unit YTD],SAMEPERIODLASTYEAR(Calendar[Date]))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Your measures should be:

 

Total units YTD = CALCULATE(SUM(Data[Units sold]),DATESYTD(Calendar[Date],"31/12"))

Total units YTD (Last year) = CALCULATE([Total unit YTD],SAMEPERIODLASTYEAR(Calendar[Date]))

 

Hope this helps.


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

Hi @tlehner926.

 

According to your description, I found you are try to use time intelligence function to calculate with not existed date in calendar. I think it may caused the issue.

 

Can you please provide some sample data/pbix file for testing? It will be help for clarify your issue and testing.

 

BTW, you can also take a look at following links about time intelligence functions:

Time Intelligence in Power BI Desktop

Secret of Time Intelligence Functions in Power BI

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks for this input - good insights especially on mark as date.

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.