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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Previous Date value based on the date selection

Hi Everyone,

 

I'm trying to get the Previous Date's value for each Team. Below is the way I have relations in my model.  And in the dashboard, Date slicer is there (Dates Master Table). So, based on the selected date, I need to show  a table with the Maxdate selected-1 for each team.

 

vishnupriyak_1-1641385483100.png

 

 

If the Date range is from 03-01-2022 to 04-01-2022, my table  need to show the data related to 03-01-2022.

Desired way 

TeamValue
X2
Y5
Z1

 

 

I have tried  to use this below DAX. But it is giving me the totals as correct but the values as blanks.

 

Before Date values =
var x = CALCULATE(MAX('Dates'[Date]))
return
CALCULATE(SUM('TransactionTable'[Value),FILTER(all('TransactionTable All'),[Date] = (x-2)))
 
 
Can anyone please help me to get this?
 
Thank you in advance
Vishnu Priya
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Use independent date table as slicer and create a measure like below:

Measure = 
var _previous = EDATE(MAX('Date'[date]),-1)
return
CALCULATE(SUM(TransactionTable[value]),FILTER(TransactionTable,TransactionTable[Date]=_previous))

Capture.PNG

Or create a measure as below and add it to visual filter set value = 1:

Measure 2 = 
var _previous = EDATE(MAX('Date'[date]),-1)
return
IF(SELECTEDVALUE('TransactionTable'[Date])=_previous,1,0)

Capture.PNG

 

Best Regards,

Jay

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Anonymous ,

 

Use independent date table as slicer and create a measure like below:

Measure = 
var _previous = EDATE(MAX('Date'[date]),-1)
return
CALCULATE(SUM(TransactionTable[value]),FILTER(TransactionTable,TransactionTable[Date]=_previous))

Capture.PNG

Or create a measure as below and add it to visual filter set value = 1:

Measure 2 = 
var _previous = EDATE(MAX('Date'[date]),-1)
return
IF(SELECTEDVALUE('TransactionTable'[Date])=_previous,1,0)

Capture.PNG

 

Best Regards,

Jay

There @Syndicate_Admin ,

Thank you! I just removed all relations and recreated. Now its working.

amitchandak
Super User
Super User

@Anonymous , You should prefer date table. if two date are selected , measure like this for min date

new measure =
var _max = minx(allselected(Date),Date[Date])
return
calculate( SUM('TransactionTable'[Value), filter('Date', 'Date'[Date] =_min ))

 

For the last date the previous date refer

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you @amitchandak  for the reply. I have  tried  this. And  I cant use MINX because I need  the previpus days data(If the date range is 2-01-2022 to 04-01-2022, I need the 3rd data. and if the range is from 02-01-2022 to 05-01-2022, I need 04-01-2022 data). So I have tried _max-1 in the filter context.

Still, it is  giving  me the values in the table  as blanks and  totals are correct.

 

 

@Anonymous , Then try

new measure =
var _max = maxx(allselected(Date),Date[Date]) -1
return
calculate( SUM('TransactionTable'[Value), filter('Date', 'Date'[Date] =_max ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Thank you for the reply. I have tried that with maxdate-1. Still it is  showing the totals only not the values.

If the date range is from 02-01-2022 to 04-01-2022, my table  need to show the data related to 03-01-2022.

TeamValue
X2
Y5
Z1

 

I need the output by the Team name like above but im getting  the resuts as  below with only totals not the values.

TeamValue
X 
Y 
Z 
Total8

 

Can anyone please help me out?

 

Thanks in advance,

Vishnu Priya

@Anonymous 

pls see the attachment below





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

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors