Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
albertax
Frequent Visitor

Using a measure to change data to weekly or monthly date range

Hi, I am wondering if  you are able to help me with a measure where i am wanting people to be able to filter to the last 7 days (weekly) or last 30 days monthly by clicking on a slicer that is powered by a measure.

Demonstrated below, expected behaviour
- User clicks on monthly, it changes the data in the Matrix Tables to monthly data only

- User clicks on weekly, it changes the data in the Matrix Tables to weekly data only  

albertax_0-1649423167368.png

I have a table called Metrics, which these three options: Weekly, Monthly, Year.


My switch statement which i wrote is not working, and is as follows: 

MetricsSwitch =
SWITCH(
TRUE(),
"Weekly" IN ALLSELECTED(Metrics[Metrics], FILTER(DATESMTD('CCC - 08042021'[EventDate]),
"Monthly" IN ALLSELECTED(Metrics[Metrics], FILTER(DATESYTD('CCC - 08042021'[EventDate])
)

Is anyone able to help me out here? I'm hoping to build this level of switching in across my dashboard for my users, as they are always wanting to compare (quickly) weekly and monthly data.

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @albertax ,

You can refer the following links to get it.

Change time period (week, Month, Quarter...) on slicer selection

yingyinr_0-1649749979355.png

Power BI How To: Adding a Monthly/Annual switch to a Dashboard

Measure to show the data as "daily","weekly","monthly" in power bi?


There are 2 common ways to make this work :

Way-1 : Utilizing Power Query

  1. Create a "Date Table" using the date column in power query
  2. Add 3 calculated columns that extracts month, week and day info from the "Date" column in the newly created "Date Table".
  3. Now, unpivot the "month", "day" and "year" columns and load the file.
  4. Create a one to many relationship with "Date" columns as common in both tables and there you go.

Way-2 (Using Drill-through buttons).

Use the recent feature update of Power BI, i.e., drilling the data using buttons. So, you just need to create a date hierarchy and then drill through using buttons for "month", "week"and "day".

I hope this will help you.

If you still got the doubt then please send me the dataset and I will give you an detailed explanation on this.


Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @albertax ,

You can refer the following links to get it.

Change time period (week, Month, Quarter...) on slicer selection

yingyinr_0-1649749979355.png

Power BI How To: Adding a Monthly/Annual switch to a Dashboard

Measure to show the data as "daily","weekly","monthly" in power bi?


There are 2 common ways to make this work :

Way-1 : Utilizing Power Query

  1. Create a "Date Table" using the date column in power query
  2. Add 3 calculated columns that extracts month, week and day info from the "Date" column in the newly created "Date Table".
  3. Now, unpivot the "month", "day" and "year" columns and load the file.
  4. Create a one to many relationship with "Date" columns as common in both tables and there you go.

Way-2 (Using Drill-through buttons).

Use the recent feature update of Power BI, i.e., drilling the data using buttons. So, you just need to create a date hierarchy and then drill through using buttons for "month", "week"and "day".

I hope this will help you.

If you still got the doubt then please send me the dataset and I will give you an detailed explanation on this.


Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
johnt75
Super User
Super User

Your best bet is probably a calculation group with items for the different granularities. You can put the items into a slicer and it will do exactly what you're after

Hi @johnt75
I kind of liked your idea. I appreciate if you have some sample file that you can share.

Thanks,
Amit

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.