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
tsynenkyy
Helper II
Helper II

Compare CY vs same period selected year

Hi,

 

Currenly Im available just to make a comparison between CY and PY:

 

Spend Selection CY = [Spend Amount Original]
Spend Selection PY = CALCULATE([Spend Amount Original],PARALLELPERIOD(DIM_TIME[Date],-12,MONTH))
 
tsynenkyy_0-1650544056810.png

This works great, but the new requierement is selecting the both years I want to compare.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I would set up 2 new tables for use on the slicers, 

First Year = ALLNOBLANKROW('Date'[Year])

Second Year = ALLNOBLANKROW('Date'[Year])

Do not connect these tables to anything in the model. The create 2 measures as

Value for first year = CALCULATE( [Spend Amount Original], TREATAS( 'First Year'[Year], 'Date'[Year]) )

Value for second year = CALCULATE( [Spend Amount Original], TREATAS( 'Second Year'[Year], 'Date'[Year]) )

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

I would set up 2 new tables for use on the slicers, 

First Year = ALLNOBLANKROW('Date'[Year])

Second Year = ALLNOBLANKROW('Date'[Year])

Do not connect these tables to anything in the model. The create 2 measures as

Value for first year = CALCULATE( [Spend Amount Original], TREATAS( 'First Year'[Year], 'Date'[Year]) )

Value for second year = CALCULATE( [Spend Amount Original], TREATAS( 'Second Year'[Year], 'Date'[Year]) )
amitchandak
Super User
Super User

@tsynenkyy , Try like

 

Spend Selection PY = CALCULATE([Spend Amount Original],dateadd('DIM_TIME'[Date],-1,Year))

 

or

 

Spend Selection PY = CALCULATE([Spend Amount Original],SAMEPERIODLASTYEAR('DIM_TIME'[Date]))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.