Forum Discussion
Date in Power BI
Hello All,
I am new to Power BI.
I have a report where I need to filter the data based on my slicer value.
Lets say if my slice value is Daily then I need to show only last 12 days data
and If my slice value is Weekly then I need to show only last 5 Weeks data.
Could any one please help, how to do this
8 Replies
- KNP
Super User
Hi Anonymous,
You need to provide more info than this.
This post will explain how to get your questions answered quickly.
If I had to take a guess, this video may help...
https://www.youtube.com/watch?v=fKygF7VEJnQ&t=17s&ab_channel=BIElite
- Samarth_18
Community Champion
Hi Anonymous ,
Please try below measure :-
Measure = VAR selected_value = SELECTEDVALUE ( Slicer_Table[Slicer_value] ) VAR last_12_day = IF ( CALCULATE ( MAX ( Dates[Date] ), FILTER ( Dates, Dates[Date] >= TODAY () - 12 && Dates[Date] <= TODAY () ) ), 1, 0 ) VAR last_5_week = IF ( CALCULATE ( MAX ( Dates[Date] ), FILTER ( Dates, Dates[Date] >= TODAY () - 35 && Dates[Date] <= TODAY () ) ), 1, 0 ) RETURN IF ( selected_value = "Daily", last_12_day, last_5_week )and use it as filter:-
Refer below file for reference.
Thanks,
Samarth
- AnonymousNot applicable
Hi Samarth_18 ,
Could you please let me know where I need put my slicer values here (Daily and Weekly )
I dont see in the measure you created.
Please correct me If I am wrong
Measure = VAR selected_value = SELECTEDVALUE ( Slicer_Table[Slicer_value] ) VAR last_12_day = IF ( CALCULATE ( MAX ( Dates[Date] ), FILTER ( Dates, Dates[Date] >= TODAY () - 12 && Dates[Date] <= TODAY () ) ), 1, 0 ) VAR last_5_week = IF ( CALCULATE ( MAX ( Dates[Date] ), FILTER ( Dates, Dates[Date] >= TODAY () - 35 && Dates[Date] <= TODAY () ) ), 1, 0 ) RETURN IF ( selected_value = "Daily", last_12_day, last_5_week )- Samarth_18
Community Champion
Anonymous , Replace the below table with your slicer table which is having value like daily or weekly.
Slicer_Table[Slicer_value]