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

Time Calculations - Pr Yr formula not working

Hello!

 

I'm working on creating my first report in PowerBi and have had to use metric time calculations due to my ISO calendar 4-4-5 which goes across years. I've been able to create metrics such as "YTD units" that are pulling back correctly, but for my "Prior YTD" metrics, it does not seem to be working and I don't know what I am missing.

 

I've checked and my fiscal_year_nr is formatted as #, so it should be able to subtract. 

 

YTD Formula that is working:

FYTD Units = IF (
HASONEVALUE ( 'Date'[Fiscal_year_nr] ),
CALCULATE (
SUM ( Invoice_Detail[Units] ),
FILTER (
ALL( 'Date' ),
'Date'[Fiscal_year_nr] = VALUES ( 'Date'[Fiscal_year_nr] )
&& 'Date'[Date] <= MAX ( 'Date'[Date] )
)
),
BLANK ()
)

 

Prior Year To Date formula (NOT WORKING):

PYTD Units =
IF (
HASONEVALUE ( 'Date'[Fiscal_year_nr] ),
CALCULATE (
SUM (Invoice_Detail[Units]),
FILTER (
ALL ( 'Date' ),
'Date'[Fiscal_year_nr] = VALUES ( 'Date'[Fiscal_year_nr] ) - 1
&& 'Date'[Date] <= MAX ( 'Date'[Date] )
)
),
BLANK ()
)

 

Thank you

 

2 REPLIES 2
jthomson
Solution Sage
Solution Sage

What results are you actually getting that make you think it's not working? The two formulas look identical

Sorry- must have copied the Pr YTD formula incorrectly, I've updated it in the post. 

 

The formula is returning the Prior Year number, however it is returning the FULL month number vs. the "to-date" prior month. For example, it is pulling data for October last year and not October last year through 10/18.

 

Thank you!

 

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.