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
IF
Post Prodigy
Post Prodigy

Previous year December value

Hi

I want to show the value of December previous year. I followed the steps that is posted but couldn't get the result.

here is the measure:

MeasureValue1 = CALCULATE(SUM('Table'[value1]),FILTER('Table', 'Table'[Year]=SELECTEDVALUE('Table'[Year])-1&&'Table'[Month]=12))

 

Second measure:

MeasureValue1(b) =
VAR _selectedyear=SELECTEDVALUE('Table'[Date])-1
return CALCULATE(SUM('Table'[value1]), FILTER(ALL('Table'), YEAR('Table'[Date])=_selectedyear&&MONTH('Table'[Date])=12))
 
both doesn't give me result.
 

NameMonth.YearDatevalue1value2

a12.20191.12.201912
b12.20191.12.201912
a01.201901.1.201945
b01.201901.1.201945
a12.20181.12.201878
b12.20181.12.201878
a02.20191.2.20191122
b02.20191.2.20191122
a12.20171.12.20171214
b12.20171.12.20171315
a03.20171.03.20171820
b03.20171.03.20171921
a12.20201.12.20203133
b12.20201.12.20203234
a04.20201.04.20203739
b04.20201.04.20203840
a12.20191.12.20194547
b12.20191.12.20194648

 

If anymonth in 2020 is selected the result should be 93, for selection of 2019, it should be 14; and it should be 25 for selection of any value in 2018.

the file is available at: https://www.dropbox.com/s/g6cs2tsbk9x6s0k/December%20previous%20year%28share%29.pbix?dl=0

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@IF 

you can try this

 

Measure = 
VAR yr=right(SELECTEDVALUE('Table'[Month.Year]),4)-1
return SUMX(FILTER(all('Table'),'Table'[Month.Year]="12."&yr),'Table'[value1])

1.PNG

 

please kindly check the below pbix file.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@IF 

you can try this

 

Measure = 
VAR yr=right(SELECTEDVALUE('Table'[Month.Year]),4)-1
return SUMX(FILTER(all('Table'),'Table'[Month.Year]="12."&yr),'Table'[value1])

1.PNG

 

please kindly check the below pbix file.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@IF , with help from date table

last Dec =

var _mon = month(today())

return

CALCULATE(SUM(Table[Value]),DATESMTD(dateadd('Date'[Date],-1*_mon ,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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.