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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.