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

Override date filter in Power BI with months before the filtrate

Hi,

I'm trying to make sure that when I filter the month, the table returns the 5 months before that filtered month.
I'm new to dax language and I don't have so much advanced knowledge and I found a way to solve this link:

 

https://towardsdatascience.com/override-date-filter-in-power-bi-743b9e8b9b2

What I did was create this measure

 

 

 

Value of docs -5 month = VAR MaxDate = MAX (Date [Date])
VAR MinDate = DATE (YEAR (MaxDate), MONTH (MaxDate) -5, DAY (MaxDate))
VAR Result = CALCULATE (
DISTINCTCOUNT (Table [DOC_ID]),
FILTER (table,
table [Date]> = MinDate && table [Date] <= MaxDate)
)
RETURN
Result

 

 

the table [data] is the main date of my data table

and the date [date] is a table just like the date, as if it were a fatto table

 

You are returning the last 5 months regarding the maximum date not what was filtered, how would you do this measure to solve this?

 

Screenshot_8.png

 

 

2 REPLIES 2
jameszhang0805
Resolver IV
Resolver IV

Returns the Last N months regarding the selected month. Hope it is useful to you.

Testing1.gif

Last N Month.pbix 

rfigtree
Resolver III
Resolver III

try changing the filter in your return to this

 

FILTER (     all(table)     ,Table [Date]> = MinDate && table [Date] <= MaxDate)

 

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.

Top Solution Authors