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
Anonymous
Not applicable

This year date value vs (this year date -364) value

Hi I have two tables, one is a date table, another one is a sales table. These two tables are connected through Order Date (Sales table) to Date (Date table)

 

I have a measure as below, which gives me the value of fiscal year 2019 total sales $.

 

This Year Sales = calculate(sum('Sales Table'[Sales $]),filter(Date Table,Date Table[Date] <= Date Table[Fiscal Year 2019 End Date] && Date Table[Date] >= Date Table[Fiscal Year 2019 Start Date]))

 

In my design view, when I select a specific date from date table, the above measure will give me the sales $ for that date in 2019.

 

Now I would like also have another measure to give me the sales $ for (same date -364) in 2018. 

 

For example, when select 1/1/2019, this year sales measure gives me the sales $ on 1/1/2019, and I would like to see the sales $ on (1/1/2019 -364) = 1/2/2018 from the new measure.

 

I have tried to use DAX with sameperiodlastyear, which this one gives me the value for 1/1/2018 instead of 1/2/2018. I think this sameperiodlastyear calculation is based on date minus 365, but I would make it as date minus 364.

 

Thanks in advance!!

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

You may try DATEADD() function instead:

DATEADD(<dates>,<number_of_intervals>,<interval>)  

https://docs.microsoft.com/en-us/dax/dateadd-function-dax

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

You may try DATEADD() function instead:

DATEADD(<dates>,<number_of_intervals>,<interval>)  

https://docs.microsoft.com/en-us/dax/dateadd-function-dax

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@v-yuta-msft 

 

Thank you so much for the help!!

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.