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
AshPower
Frequent Visitor

Display either last 7 dates or 'ALL' the dates

Using Slicer I want  user to be able to display last week data or all.

currently I have data for 30 days, it will grow as days pass by.

Right now using following calc column I am able to display last 7 days or (30 days - 7 days). 

 

Time Frame = if(AND(DailyStatus[Creation Date].[Date]>=[Today]-7,DailyStatus[Creation Date].[Date]),"Last 1 week","All")

I would like to diaplay slicer option of last 7 days or ALL

 

Thanks!

date Dimdate DimLast 2 weeksLast 2 weekswant to show all but displays (All-last 2 week)  dateswant to show all but displays (All-last 2 week) dates

4 REPLIES 4
v-huizhn-msft
Employee
Employee

Hi @AshPower,

Have you resolved your issue? If you have, please mark the corresponding reply as answer. Or welcome to share your workaround.

Best Regards,
Angelia

GilbertQ
Super User
Super User

Hi @AshPower

 

What I would do in your situation, is I would have created a date table, and linked my main (FACT Data) to my Date table via the date column.

 

Then what I would do is the similar steps described below, to create a new column in my Date Table which would allow me to use a Slicer to show the last 7 days or all. In my blog post below it is for the current month, but we could easily change this to be for the last week.

 

You will then have to add a column in the Date Table with the following which will be going back 7 Days from Todays Date

 

Date.From(Date.AddDays(DateTimeZone.SwitchZone(DateTimeZone.FixedLocalNow(),10),-7))

NOTE: IN the above I have offset my time to 10 hours being in AEST, so you might need to change that to your local timezone.

 

Then I added another conditional column which then calculates if it is within the Past 7 Days

if [Calendar Date] >= [Past 7 Days] and [Calendar Date] <= [Current Date]
then "Past 7 Days"
else "All"

 

So that now my column will only have the value of the "Past 7 Days" when it is within the date range.

 

Power BI – Getting your report to always filter this month’s data dynamically

NOTE: I have uploaded the file to the blog post above which can show you the changes above.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Hi

I am sorry but it is not working for me, still displaying past week or misus past week from all instead of All.

parry2k
Super User
Super User

here is an interesting link , hope it is helpful, if need more help, let me know

 

http://analyticsavenue.com/power-bi-timeperiod-slicer-for-last-7-dayslast-30-days/



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.