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
Anonymous
Not applicable

Display Values only for the last year if no filter is selected - DAX

Hello everyone,

I have a question that I think is simple but I'm not getting it.

 

I wanted to see values only in the last year, if no filter is selected:

 

YEAR: (all)

 

Month Value

Jan 20

  
Feb 20  
Mar 20  
(....)  

Dec 20

  
Jan 21 123
Feb 21 3232
Mar 21 32323


Thank you very much in advance for your help,
Simão

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Assume you have a year column too

 


measure =
var _1 = year(today())-1
return
if(isfiltered(Table[Year]) , calculate(sum(Table[Value])),calculate(sum(Table[Value]), filter(Table, Table[year] =_1)))

 

or

 


measure =
var _1 = year(today())-1
return
if(isfiltered(Table[Month]) , calculate(sum(Table[Value])),calculate(sum(Table[Value]), filter(Table, Table[year] =_1)))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Assume you have a year column too

 


measure =
var _1 = year(today())-1
return
if(isfiltered(Table[Year]) , calculate(sum(Table[Value])),calculate(sum(Table[Value]), filter(Table, Table[year] =_1)))

 

or

 


measure =
var _1 = year(today())-1
return
if(isfiltered(Table[Month]) , calculate(sum(Table[Value])),calculate(sum(Table[Value]), filter(Table, Table[year] =_1)))

Anonymous
Not applicable

Thank you very much!

This is just what I was looking for!

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.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.