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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.