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
sakamotothais
Helper III
Helper III

Dynamic filter for a measurement

Hi

 

I have a measure with today's date D 0 and a measure with yesterday's date D -1.

 

How can I get dynamic when I filter a date on a slicer?

For example, when selecting on filter day 26 bring in D 0 result of day 26 and in D -1 result of the previous day 25

If I select on filter day 25 bring in D 0 result of day 25 and in D -1 result of the previous day 24 And so on. Can someone help me?

 

thanks

6 REPLIES 6
v-caliao-msft
Microsoft Employee
Microsoft Employee

@sakamotothais,

 

Please refer to the steps below to achieve your requirement.

  1. Create a date table, and do not create relationship between this date table and your original table.
    Table = CALENDAR(DATE(2017,4,1),DATE(2017,6,30))
  2. Create a measure in your original table.
    Measure =
    var selectitemed = MAX('Table'[Date])
    return IF((1*(MAX(Table1[Date])-selectitemed)=0||1*(MAX(Table1[Date])-selectitemed)=-1),1,0)
  3. Add this measure to your visual filter like below.
    Capture.PNG

Result.
Capture1.PNGCapture2.PNG

 

Regards,

Charlie Liao

 

 

Thanks for the example, it worked well.


But it still is not what I need.


I need to separate. A measure that contains today's date, and a measure that contains yesterday's date according to the date filter.
Then check the variance in the graphs between the two results.

 

Thanks

MattAllington
Community Champion
Community Champion

Have a read of my article here https://exceleratorbi.com.au/dax-time-intelligence-beginners/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Thanks,

 

But I'm really not able to put the formula all filter, or filter allselect in the formula with SUMX

 

Please can anyone help me, structure the code for d-1. What to get yesterday's filter date?

 

 


@sakamotothais wrote:
 


But I'm really not able to put the formula all filter, or filter allselect in the formula with SUMX

 

 


  You can extract yesterday's filter date generally by using the piece of code MAX(Calendar[Date])-1 where Calendar[Date] is used to filter your visual.  It is normally used inside a calculate

 

 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

It does not work when I change the date in the dtt_data_captura filter, it does not return the result from yesterday's date Daily Variance D -1 = SUMX ( FILTER (QL2_Alerts, QL2_Alerts[dtt_data_captura] = MAX (QL2_Alerts[dtt_data_captura])-1), QL2_Alerts[flt_base])

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