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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BI_devlpr
Regular Visitor

Include fields/columns sameperiodlastyear

Hi All,

 

I am trying to calculate last year value. I am using sameperiod last year to achieve this functionality. Keeping in mind that same period last year is a contiguous function, I am using a calendar table for time value. Now this measure gives me just the sum of date . I will have to include region, department and site level information. But my formula is immune to all these fields. I am unsure of what needs to be used here. Please help

 

 

so far I tried theseYOY.JPG

last_year = 
CALCULATE(AVERAGE('Overtime'[OT_Value]),
FILTER(all('Calendar'),'Calendar'[year]= 'Calendar'[OT LastYear Value]))

Over Time Last Year = 
CALCULATE(AVERAGE('Overtime'[OT_Value]),
DATEADD('Calendar'[calendar_date],-1,YEAR), ALLSELECTED('Overtime'[OT_Value]),
ALLEXCEPT('Calendar','Calendar'[calendar_date]))

OT Last Year = 
CALCULATE(AVERAGE('Overtime'[OT_Value]),
SAMEPERIODLASTYEAR('Calendar'[calendar_date]),
ALLEXCEPT('Calendar','Calendar'[calendar_date]))

 

 

5 REPLIES 5
v-xjiin-msft
Solution Sage
Solution Sage

Hi @BI_devlpr,

 

In your scenario, you want to get the measure values also be based on region, department and site group. Right?

 

Please try this, see if it helps:

 

last_year =
CALCULATE (
    AVERAGE ( 'Overtime'[OT_Value] ),
    FILTER (
        ALL ( 'Overtime' ),
        'Overtime'[region] = MAX ( 'Overtime'[region] )
            && 'Overtime'[department] = MAX ( 'Overtime'[department] )
            && 'Overtime'[site] = MAX ( 'Overtime'[site] )
    ),
    FILTER ( ALL ( 'Calendar' ), 'Calendar'[year] = 'Calendar'[OT LastYear Value] )
)

By the way, if you can share us some sample data and the expected result. It'll help us a lot to provide more accurate solutions.

 

Thanks,
Xi Jin.

@v-xjiin-msft I tried this one and it gave me a null value. When I am trying to use different functions, the formula just considers the sum of measure and date, it ignores the rest of it. Is it because sameperiod last year is a cintiguous function. Perplexed !! 

Hi @BI_devlpr,

 

Then please share us more detailed information like some sample data which we can copy and paste directly and its corresponding expected result. So that we can make some tests rather than just guessing.

 

Thanks,
Xi Jin.

MattAllington
Community Champion
Community Champion

Is your calendar table at the day level?

is the month/year column in your visual from the calendar table?

 

More background here https://exceleratorbi.com.au/power-pivot-calendar-tables/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Yes, my calendar table is at day level. The month/year column is from the calender table. All dates are joined using calendar key from other tables. I tried using the date column to join the tables. It did not help me. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors