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

Previous YEAR vs Selected Year

Hi guys,

 

Please help with this DAX

 

I need show the value by select YEAR vs PREVIOUS YEAR

 

I am using this expression:

 

Max Year = CALCULATE(SUM(MyTable[REAL]); FILTER ('TIMEDIM'; TIMEDIM[YEAR]=MAX(TIMEDIM[YEAR]) ) ) 

this return Real value of year

 

and 

 

Previous Year = CALCULATE(SUM(MyTable[REAL]); PREVIOUSYEAR('TIMEDIM'[DATE]))

 

However when I put this measures in my table i have a repeat of previous year for all months

 

Like this

 

I have date from:

 

 Year 2016                             2015

Month                                  Month

apr  10

jun   5                                 7

jul    4

 

However when i show in table i have all months with value 7

 

YEAR actual                           Previous

jan                                          7

feb                                          7

mar                                         7

apr 10                                     7

may                                         7

jun  5                                       7

jul   4                                       7

 

2 REPLIES 2
abhi123
Frequent Visitor

Not getting you properly but i have done something as below.

 

I have used few calculation one is for current year real value and the last year real value as below

 

Last Year Real value = IF(YEAR('Table name'[Date Field])=YEAR(NOW())-1 , 'Table name'[Real value])

 

Current Year Real value = IF(YEAR('Table name'[Date Field])=YEAR(NOW()),'Table name'[Real value])

 

REal value.png

 

 

I thnik you should attach your pbix so that i can have more idea and give you the best i can.

 

Thanks 

Abhi.

 

Eric_Zhang
Employee
Employee

@Twister8

Not clear about your data model, check the attached pbix based on my understanding.

Capture.PNG

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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