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

Filter the Power BI Report for Current Date when Opening

Hi,

 

I have the below visual in my report and my aim is the current year, current month, current week number and current day should be get selected when opening the report. 

 

2.JPG

 

For doing this, I have done the following methods. But nothings works.

 
Step 1:- I have created 4 calculated columns in my date table.
CurrentYear = YEAR(TODAY())
CurrentMonth = MONTH(TODAY())
CurrentWeek = WEEKNUM(TODAY(),1)
CurrentWeekDay = FORMAT(TODAY(),"dddd")
 
Step 2:- I have created another 4 calculated columns in my date table which are mapped to my slicers. The date table already have the columns Year, Month, WeekNumber and WeekName in it.
 
YearSlicer = IF(DateTable[Year]=DateTable[CurrentYear],YEAR(TODAY()),DateTable[Year])
MonthSlicer = IF(DateTable[Month]=DateTable[CurrentMonth],FORMAT(TODAY(),"MMMM"),DateTable[MonthName])
WeekSlicer = IF(DateTable[WeekNumber]=DateTable[CurrentWeek],WEEKNUM(TODAY(),1),DateTable[WeekNumber])
WeekDaySlicer = IF(DateTable[WeekName]=DateTable[CurrentWeekDay],FORMAT(TODAY(),"dddd"),DateTable[WeekName])

 

After performing these two steps, still I could see my slicers are asusual and not getting selected to current date as expected.

 

Please help with clear and proper way. Appreciate your efforts.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , No way to default using a function

We have to you column like this and select Current Month, Today etc

 

Month Type = Switch( True(),
eomonth(Date[Date],0) = eomonth(Today(),0) ,"Current Month" , //This Month
eomonth(Date[Date],0) < eomonth(Today(),0) && ,"Previous Month" , //last Month
eomonth(Date[Date],0) > eomonth(Today(),0) && ,"Next Month" , //last Month
[Month Year]
)

 

 


Week Type = Switch( True(),
Weekday(Date[Date],1) = Weekday(Today(),1) ,"Today" , //This Month
[Week Day]
)

 

Date Type = SWITCH(TRUE(),'Date'[Date]=TODAY(),"Today"
,'Date'[Date]=TODAY()-1,"Yesterday"
,'Date'[Date]=TODAY()-2,"2 Days Ago"
,'Date'[Date]&"")

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , No way to default using a function

We have to you column like this and select Current Month, Today etc

 

Month Type = Switch( True(),
eomonth(Date[Date],0) = eomonth(Today(),0) ,"Current Month" , //This Month
eomonth(Date[Date],0) < eomonth(Today(),0) && ,"Previous Month" , //last Month
eomonth(Date[Date],0) > eomonth(Today(),0) && ,"Next Month" , //last Month
[Month Year]
)

 

 


Week Type = Switch( True(),
Weekday(Date[Date],1) = Weekday(Today(),1) ,"Today" , //This Month
[Week Day]
)

 

Date Type = SWITCH(TRUE(),'Date'[Date]=TODAY(),"Today"
,'Date'[Date]=TODAY()-1,"Yesterday"
,'Date'[Date]=TODAY()-2,"2 Days Ago"
,'Date'[Date]&"")

Anonymous
Not applicable

@amitchandak The way which you have mentioned, we need to have the values in slicers like Current Year, Current Month, Current Week and Current Day.

 

But I need something like 2020, September, 38 and Monday. Is this possible ?

@Anonymous ,I doubt that is possible as of now.

Also check -https://www.youtube.com/watch?v=lkHFpmA4SJ4&feature=youtu.be

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.