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
orlandopowerbi
Frequent Visitor

SHOWING n last weeks of data from the MAX date filtered

Hello everyone,

 

I'm trying to display the last 4 weeks of data. In my report i have 3 date slicers for year, month and date.

 

So what i would like is that whichever date filter is applied, my visual takes the maximum date filtered and display 4 weeks back of data from that maximum, ignoring whatever month filter is applied. To be more specific, if the user filters for March, i would like to display 4 weeks back, that includes February, instead of only March numbers.

 

So far I've tried this:

 

I created a measure which calculates the maximum date.

 

Max Date = CALCULATE(MAX(Data[Date]))

 

Then, i edited the interactions so mi visual is not affected by any date slicer and create a measure like these:

 

Calls = 
VAR MAXDATE = [Max Date]
VAR MINDATE = [Max Date]-28
RETURN CALCULATE(SUM(Data[Inbound]),FILTER(Dates,(Dates[Date]<=MAXDATE && Dates[Date]>=MINDATE)))

 

So in my head, the measure would capture the Maximum date filtered so my Calls measure can retrieve only the desired data.

 

But my visual is ingoring the filter condition and diplaying everything as unfiltered.

 

Thank you very much in advance for any help or ideas provided.

 

 

 

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@orlandopowerbi , Seem correct at first look.

 

Try if this one can help

 

Calls =
VAR MAXDATE = MAXX(allselected(Data), Data[Date])
VAR MINDATE = [Max Date]-28
RETURN CALCULATE(SUM(Data[Inbound]),FILTER(Dates,(Dates[Date]<=MAXDATE && Dates[Date]>=MINDATE)))

Thank you @amitchandak , but the result seems to do the same. The visual is not reacting at all to the date slicers.

 

The weird thing is that that MAXX(allselected(Data), Data[Date]) does get the desired date but its doesnt seem to work inside the filter. 

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.