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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Noak
Helper IV
Helper IV

Time selector

Hi,

Im generating cloud report using SQL server.

I need to to let the viewer use 3 different selectors:

1.daily - shows last 24h

2.weekly - last 7 days

3.monthly - last 4 weeks

4.yearly- last 12 months

 

please help me how can i creat 3 different time selector based on 1 datetime column?

 

BR,
Noa.
1 ACCEPTED SOLUTION

Hi @Noak,

 

Cause you need 4 selections so I create filter table by "Enter data" option as Period table in picture

Screenshot 2016-12-03 23.17.36.png

 

Create new Measure with swtich options based on user's selection:

 

 

Calcualted Measure - Value = if(HASONEVALUE('Filters'[Period]),
	SWITCH(FIRSTNONBLANK('Filters'[Period],'Filters'[Period]),
	"Last 24h",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-1  )),
	"Last Week",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-7  )),
	"Last Month",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-35  )),
	"Last Year",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-365  )),
		BLANK()
	) )

(Not sure meaning of 13 months, so i let it minus 365 days, you could modify it)

 

 

 

Screenshot 2016-12-03 23.11.55.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In case you want to change the scenario with YTD, MTD, today, this week, this month, this year. You could use equal express with Today() or Month(Today()), Weeknum(Today()), Year(today())

 

 

If this works for you please accept it as solution and also give KUDOS.

View solution in original post

16 REPLIES 16
BhaveshPatel
Community Champion
Community Champion

Please refer to THIS blog post by Rob Collie. Using the Switch function to create the dynamic slicers.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Still have problem implementing the switch function..Im not a pro (new in the enviroment)

please help.

@BhaveshPatel

BR,
Noa.

Could you please upload sample data and your expectation as picture? So I could quickly help you with sample file.

My data is from SQL Server I dont have sample file , I can creat somthing by myself.

but basicly I need dynamic selector .


@tringuyenminh92 wrote:

Could you please upload sample data and your expectation as picture? So I could quickly help you with sample file.


 

@tringuyenminh92

BR,
Noa.

Thank you @tringuyenminh92 , you might have saved my day.

Basicly the end client see lot of data with interval of 5 minutes:

I want the most "elegant" way to present the data for 4 possabilities:

1. last 24h

2.last week

3.last month

4.last year

 

P.S I noticed its not possible to drill down to minutes.

 

help3.png

 

 

BR,
Noa.

Hi @Noak,


I would like to confirm about definition of 

Last 24h: is that  from NOW - 24H or today ?

Last Week: is that from now - 7 days or from first date of week to now?

Last Month is that from first date of month to now or something else?

Last Month is that from first date of year to now or something else?

Hi @tringuyenminh92,

via below:

 


@tringuyenminh92 wrote:

Hi @Noak,


I would like to confirm about definition of 

Last 24h: is that  from NOW - 24H from now

Last Week: is that from now - 7 days from now (if now its saturday 12:00AM then I need to present data from last saturday 12:00AM )

Last Month is that from first date of month to now or something else? 35d from now

Last Month is that from first date of year to now or something else?  A year will be considered as 13 months


Again thank you!

BR,
Noa.

Hi @Noak,

 

Cause you need 4 selections so I create filter table by "Enter data" option as Period table in picture

Screenshot 2016-12-03 23.17.36.png

 

Create new Measure with swtich options based on user's selection:

 

 

Calcualted Measure - Value = if(HASONEVALUE('Filters'[Period]),
	SWITCH(FIRSTNONBLANK('Filters'[Period],'Filters'[Period]),
	"Last 24h",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-1  )),
	"Last Week",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-7  )),
	"Last Month",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-35  )),
	"Last Year",CALCULATE(sum(SampleData[Value]),FILTER(SampleData,SampleData[Date] >= NOW()-365  )),
		BLANK()
	) )

(Not sure meaning of 13 months, so i let it minus 365 days, you could modify it)

 

 

 

Screenshot 2016-12-03 23.11.55.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In case you want to change the scenario with YTD, MTD, today, this week, this month, this year. You could use equal express with Today() or Month(Today()), Weeknum(Today()), Year(today())

 

 

If this works for you please accept it as solution and also give KUDOS.

Hi @tringuyenminh92,

Please explain the content of value column?

BR,
Noa.

It's your value field. You have 5 measures value in chart in the picture, don't you? or if you are counting number of countries, you could replace the sum(sample[value]) by count(SheetName[FieldColumn])] to fit your case.

Hi Again @tringuyenminh92,

 

Its not working (please via attached image)  =\.Untitled.png

 

 

BR,
Noa.

Hi @Noak

 Country is just example meaning.

Did you drag and drop  "Calculated Measure - Value" to the Value field in line chart? Coud you click to line chart and show me the Fields in there? 

Sure @tringuyenminh92

Untitled2.png

 

 

BR,
Noa.

Hi @Noak,

 

So you need replace measure: "Average of sum..." by "Calcualted Measure - value" and try the filter selections

Thank yoy @tringuyenminh92 you helped me allot!

BR,
Noa.

Hi @tringuyenminh92,

still I dont understand what you mean, My chart dont focuse on country:

let me explaing:

the chrt present:

1.Date= every 5 minutes date +time

2.MSG type(7 different types)

3.Provider(5 providers)

4.Site(5 sites)

 

My bar chart presentS: avg MSG count by date & MSG type

In order to present the data respectivly I need dynamic selector.

 

now the only missing part for me is the value column , please help.

BR,
Noa.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.