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

How to filter based on an input date

Hello,

 

I would like to filter my data based on a date input. Create a slider like to determine a day in the month and use that value inside of measures.

How could I create that (the input & the ""variable"") ?

 

Thanks for your help

6 REPLIES 6
Greg_Deckler
Super User
Super User

@Anonymous You would put a Date column into a Slicer visual. I believe that this is going to default to a slider where you can select a start and end time but you can change this using the little down caret icon in the upper right. Then, you can use this DAX to get the date/dates:

VAR __Min = MIN('Dates'[Date])

VAR __Max = MAX('Dates'[Date])


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thank you for the answer @Greg_Deckler .

 

I am trying to apply this solution, created a new table and added dummy dates inside of a column.

 

Here is the dax query that I am then using in order to try to filter the date:

 

currentMonthPunchedHours = CALCULATE(sum(punches[hours]), and(True, and(YEAR(punches[punchIn]) * 12 + MONTH(punches[punchIn]) = YEAR(TODAY()) * 12 + MONTH(TODAY()), and(YEAR(punches[punchOut]) * 12 + MONTH(punches[punchOut]) = YEAR(TODAY()) * 12 + MONTH(TODAY()), DAY('measure stuff'[breakEnd]) > DAY(punches[punchIn])))))
 
I am getting the error 'a function "placeholder" has been used in a True/False expression that is sued as a table filter expression. This is not allowed'.
 
In the dax query above, punchIn is the date to be filtered on, and breakEnd is "Max..." as mentionned in your answer.
 
Thanks for the help.
Jeanxyz
Post Prodigy
Post Prodigy

Do you have a column called 'input date' in the input table? If that's the case, you can create a dim_calendar table and link the input table to dim_calendar table based on relationship dim_calendar [date] - fact_input[input date]. 

 

You can then add a slicer to the visual, drag and drop dim_calendar[date] to the slicer. 

 

pbix sample: https://www.dropbox.com/s/8nzzp6mxlt4871x/filter%20test.pbix?dl=0

Anonymous
Not applicable

I do have 2 dates columns that I want to filter, but I want to filter both of them but only the day.

Would there be any way to do it ?

@fzpokg, Are both columns in the same table?  It's not a typical solution, but you can link both date columns to dim_calendar table, but Power BI only allows one active relationship, the other one will be inactive. You can enable the inactive relationship via userelationship(). 

 

Here is DAX guide on userelationship()

https://dax.guide/userelationship/

 

 

 

Anonymous
Not applicable

Both are in the same Table, but I would like to be able to use the day number to filter on another table.

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.