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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
amandabus21
Helper V
Helper V

Dax date help

Our fiscal year is July 1st - June 30th. 
 
We currently have 2023 data for July - January.
 
I am trying to comparing last years 2022 data for July - January.
 
The formula below gives me what I need. However, is there a way I can automate to alwayas compare available dates from this year?
 
for example, when we get february, i I dont want to have to go in every month and change the formula to end date "2022, 02,28"
 
 
 
Last Year comparsion to this period =

VAR StartDate = DATE ( 2021,07,01 )
VAR EndDate =   DATE ( 2022, 01, 31 )

RETURN
 {
     CALCULATE(
         CALCULATE( [Sum of KPI],
         SAMEPERIODLASTYEAR('Dim DimDate'[Full_Date_Alternate_Key].[Date]) ),
         'Dim DimDate'[Full_Date_Alternate_Key] >= StartDate &&
         'Dim DimDate'[Full_Date_Alternate_Key] <= EndDate
     )
 }
7 REPLIES 7
amandabus21
Helper V
Helper V

basically

VarStart Date = Start of last fiscal year

end date  = lastest date available in data table 

any help is apprecaietd!

 

Can you please post a data example for borh tables: How you define start last fiscal year? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




We are currently in Fiscal Year 2023. So Calenadr Dates:  July 2022 - June 2023. 

 

Last 2022 fiscal year would be: Calendar dates : July 2021 - June 2022

 

We have data for 2023 fiscal year and want to compare it to how we were doing this time last year. 

amandabus21_0-1678977863158.png

 

amandabus21
Helper V
Helper V

Just getting a blank value. 

Is the start date, giving me a start date of the last fiscal year? (July 1st)

andhiii079845
Solution Sage
Solution Sage

My fault, enddate is wrong. The solution:

VAR EndDate = DATE(YEAR(StartDate), MONTH(StartDate)-12, DAY(StartDate))

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




andhiii079845
Solution Sage
Solution Sage

you can use a the max function. if you have a table with the current data and the new date.

you can say VAR startdate = max(table[datecolumn]) and you can also change your enddate if you want. 

VAR enddate =  DATEADD(table[datecolumn],-12,MONTH)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I get this error:
amandabus21_0-1678913083486.png

 

 
 
test =

VAR StartDate = MAX(agency_daily_ridership[Merged FC].[Date])
VAR EndDate =   DATEADD(agency_daily_ridership[Merged FC].[Date], -12, MONTH)
RETURN
 {
     CALCULATE(
         CALCULATE( [Sum of KPI],
         SAMEPERIODLASTYEAR('agency_daily_ridership'[Merged FC].[Date]) ),
         'agency_daily_ridership'[Merged FC] >= StartDate &&
         'agency_daily_ridership'[Merged FC] <= EndDate
     )
 }

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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