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.
We have reports in Google Data Studio where adding a date filter is as simple as drag and drop but when it comes to Power BI I don't found I data picker filter.
What I am currently doing is adding a new table like,
StartDateTableFilter = CALENDAR(TODAY()-1000,TODAY()+1000)
and binding this with new parameter called StartDate.
I don't find a way to make this date filter to show one date picker UI. Is it possible?
Also, how I make sure to today's date selected by default (instead of date in 2020)?
Solved! Go to Solution.
What I've done in the past is create a calculated column in your Date table that shows "Today" for the current date, and the date otherwise. DAX something along the lines of
Selected Date =
IF( 'Date'[Date] = TODAY(),
"Today",
'Date'[Date] & "" --note the concatenation of an empty string onto the Date field so that you have one data type in the column
)
You'll then have to bind your parameter to this new calculated column, and use it in your date slicer. Finally, you'll need to modify your power query to use this parameter. Remember, it's now a string, so you'll likely have to convert it to a date in whatever source you're using, and convert the value of "Today" to today's date.
For example, I was using SQL as a source, and had to modify my embedded query - one spot of which was updated below:
"SELECT [Date] as [DateDQ]#(lf)#(tab),
cast(case when MonthOfYear > "& Number.ToText(Date.Month(if ThroughDateParam = "Today" then DateTime.Date(DateTime.LocalNow()) else Date.FromText(ThroughDateParam))) &" or (MonthofYear = "& Number.ToText(Date.Month(if ThroughDateParam = "Today" then DateTime.Date(DateTime.LocalNow()) else Date.FromText(ThroughDateParam))) &" and [DayOfMonth] > "& Number.ToText(Date.Day(if ThroughDateParam = "Today" then DateTime.Date(DateTime.LocalNow()) else Date.FromText(ThroughDateParam))) &") then CalendarYear + 1 else CalendarYear end as varchar(4)) end as [Year Scope]
hth
What I've done in the past is create a calculated column in your Date table that shows "Today" for the current date, and the date otherwise. DAX something along the lines of
Selected Date =
IF( 'Date'[Date] = TODAY(),
"Today",
'Date'[Date] & "" --note the concatenation of an empty string onto the Date field so that you have one data type in the column
)
You'll then have to bind your parameter to this new calculated column, and use it in your date slicer. Finally, you'll need to modify your power query to use this parameter. Remember, it's now a string, so you'll likely have to convert it to a date in whatever source you're using, and convert the value of "Today" to today's date.
For example, I was using SQL as a source, and had to modify my embedded query - one spot of which was updated below:
"SELECT [Date] as [DateDQ]#(lf)#(tab),
cast(case when MonthOfYear > "& Number.ToText(Date.Month(if ThroughDateParam = "Today" then DateTime.Date(DateTime.LocalNow()) else Date.FromText(ThroughDateParam))) &" or (MonthofYear = "& Number.ToText(Date.Month(if ThroughDateParam = "Today" then DateTime.Date(DateTime.LocalNow()) else Date.FromText(ThroughDateParam))) &" and [DayOfMonth] > "& Number.ToText(Date.Day(if ThroughDateParam = "Today" then DateTime.Date(DateTime.LocalNow()) else Date.FromText(ThroughDateParam))) &") then CalendarYear + 1 else CalendarYear end as varchar(4)) end as [Year Scope]
hth
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
106 | |
105 | |
86 | |
72 |