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
ax80
New Member

USERELATIONSHIP WITH PREVIOUS YEAR DATE

Hi all,

I'm using USERELATIONSHIP in a formula with dates and I need to substitute year of selected dates with previous year.

Dates are used a slicer on the page with yerarchy Year/Quarter/Month.

 

My current formula is this:

Amount =
CALCULATE(SUM(Table[Amount]);
USERELATIONSHIP('Date'[Date];Table[Document date]))
 

Any suggestion?

Thanls

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ax80 , Try like. Keep USERELATIONSHIP inside

CALCULATE( CALCULATE(SUM(Table[Amount]);
USERELATIONSHIP('Date'[Date];Table[Document date])) ,DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

or

 

CALCULATE(CALCULATE(SUM(Table[Amount]);
USERELATIONSHIP('Date'[Date];Table[Document date])),previousyear('Date'[Date]))

View solution in original post

2 REPLIES 2
Kidata
Regular Visitor

Try this:

CALCULATE(CALCULATE(SUM(Table[Amount]);

USERELATIONSHIP('Date'[Date];Table[Document date])),

SAMEPERIODLASTYEAR('Date'[Date]))


amitchandak
Super User
Super User

@ax80 , Try like. Keep USERELATIONSHIP inside

CALCULATE( CALCULATE(SUM(Table[Amount]);
USERELATIONSHIP('Date'[Date];Table[Document date])) ,DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

or

 

CALCULATE(CALCULATE(SUM(Table[Amount]);
USERELATIONSHIP('Date'[Date];Table[Document date])),previousyear('Date'[Date]))

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.