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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Dina1410
Frequent Visitor

Need help

Hi, I am trying to report on comparing record counts between current and past years. I tried the samelastyearperiod function and the dateadd function, but I haven't had any luck. Can you please help me? Thank you.

I created a fiscal year (starting from 1 April) calendar table (Date) that contains just dates, and I have a fact table that contains record ID and file-received dates.

I created the following two measures.

Count_recordID = count(recordID)

Previous year count = calculate(count_recordID,samelastyearperiod(Date_table[date]).

Inactivated the relationship between date table and fact table.

 

I am not getting desired output. Someone can help. Thank you.

Dina1410_1-1728384066738.png

 

 

 

1 ACCEPTED SOLUTION
Kedar_Pande
Resident Rockstar
Resident Rockstar

Reactivate the relationship between your Date table and the fact table on the date fields. This is necessary for the SAMEPERIODLASTYEAR or DATEADD functions to work properly.

 

Count_recordID = COUNT('FactTable'[recordID])
PreviousYearCount = 
CALCULATE(
[Count_recordID],
SAMEPERIODLASTYEAR('Date_table'[date])
)

Place Year from the Date table in the Rows of a table visual.
Add Count_recordID and PreviousYearCount measures to Values.

If this helped, a Kudos 👍 or Solution mark would be great!🎉
Cheers,
Kedar Pande
Connect on LinkedIn

View solution in original post

2 REPLIES 2
Dina1410
Frequent Visitor

Thank you. It works.

Kedar_Pande
Resident Rockstar
Resident Rockstar

Reactivate the relationship between your Date table and the fact table on the date fields. This is necessary for the SAMEPERIODLASTYEAR or DATEADD functions to work properly.

 

Count_recordID = COUNT('FactTable'[recordID])
PreviousYearCount = 
CALCULATE(
[Count_recordID],
SAMEPERIODLASTYEAR('Date_table'[date])
)

Place Year from the Date table in the Rows of a table visual.
Add Count_recordID and PreviousYearCount measures to Values.

If this helped, a Kudos 👍 or Solution mark would be great!🎉
Cheers,
Kedar Pande
Connect on LinkedIn

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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