cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
dsilveira Frequent Visitor
Frequent Visitor

Timeline slicer default to previous day

Hi everyone!
I have a timeline that allow to show me all my sales since 2002 day to day, but the most important day for me is "Yesterday" I would like show by default this value in my timeline. (To select that day ("yesterday") in all these day is tricky because it is at the end of the list). Or maybe the solution is order the timeline desc, and in this case "yesterday" is at the begining of the list.

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator Eric_Zhang
Moderator

Re: Timeline slicer default to previous day


@dsilveira wrote:

Thanks @KHorseman

For the moment I'm using your solution, but really I would like work with the timeline because in some moments I like check the sales in the last month or maybe the last year or last week (I would like see in other range of time, BUT I usually check "yesterday").

For that, I would like keep the timeline and its functionalities.

 


Then just keep the timeline as it is. If you usually check "yesterday", create a measure and put it in an individual visual constantly, then you don't have to check "yesterday" any more. You can check the sales in last week,month,year and it won't affect the "yesterday" visual.

 

A measure based on a calendar table from @KHorseman would be like

 

Yesterday Measure =
CALCULATE (
    SUM ( yourTable[Column] ),
    FILTER ( ALL ( yourTable), RELATED ( DateTable[Day] ) = "yesterday" )
)

 

12 REPLIES 12
Super User
Super User

Re: Timeline slicer default to previous day

I hope you're using a date table. It makes these things much easier. Add a custom column to your date table:

 

Day = IF(
	DateTable[Date] = TODAY() - 1.
	"Yesterday",
	DateTable[Date]
)

 

If you want to get fancy,

 

Day = IF(
	DateTable[Date] = TODAY() - 1.
	"Yesterday", 
	IF(
		DateTable[Date] = TODAY(),
		"Today",
		DateTable[Date]
	)
)

Use that column in your slicer, select "Yesterday", and it will always hold onto yesterday as the default selection.

 

If you're not using a date table in your data model... use a date table.

dsilveira Frequent Visitor
Frequent Visitor

Re: Timeline slicer default to previous day

Thanks @KHorseman

For the moment I'm using your solution, but really I would like work with the timeline because in some moments I like check the sales in the last month or maybe the last year or last week (I would like see in other range of time, BUT I usually check "yesterday").

For that, I would like keep the timeline and its functionalities.

 

Some another idea, please...

 

Thanks!

Moderator Eric_Zhang
Moderator

Re: Timeline slicer default to previous day


@dsilveira wrote:

Thanks @KHorseman

For the moment I'm using your solution, but really I would like work with the timeline because in some moments I like check the sales in the last month or maybe the last year or last week (I would like see in other range of time, BUT I usually check "yesterday").

For that, I would like keep the timeline and its functionalities.

 


Then just keep the timeline as it is. If you usually check "yesterday", create a measure and put it in an individual visual constantly, then you don't have to check "yesterday" any more. You can check the sales in last week,month,year and it won't affect the "yesterday" visual.

 

A measure based on a calendar table from @KHorseman would be like

 

Yesterday Measure =
CALCULATE (
    SUM ( yourTable[Column] ),
    FILTER ( ALL ( yourTable), RELATED ( DateTable[Day] ) = "yesterday" )
)

 

shilpib Regular Visitor
Regular Visitor

Re: Timeline slicer default to previous day

Hi

 

Could not really figure out how it was implemented.

I have a timeslicer with date field and i want to make yesterday as default. I am using dircet query , can you helpme how to fix this.

I dont have datecalendar .

 

Regards

SHilpi

shilpib Regular Visitor
Regular Visitor

Re: Timeline slicer default to previous day

HI

 

When i am using it its giving

Day = IF(
datevalue('Date'[Date]) = TODAY() - 1;
"Yesterday"; VALUE('Date'[Date])
)

Expressions that yield variant data-type cannot be used to define calculated columns.

 

how should i use it?

 

Regards

Shilpi

 

 

Super User
Super User

Re: Timeline slicer default to previous day

@shilpib you have two return clauses in that function that each return a different type of data. The word "Yesterday" is text and VALUE('Date'[Date]) explicitly casts the date as a date type. Both clauses must either return explicit text or a direct column reference that the function can re-cast as text on return. So take out the VALUE() function. See my original formula structure above.

shilpib Regular Visitor
Regular Visitor

Re: Timeline slicer default to previous day

Hi

yes i casted them to same datatype now but still i cant set yesterday as default value in timeslicer. Looks like we cant set any default date in time slicer .

 

 

Super User
Super User

Re: Timeline slicer default to previous day

If you're talking about the timeline custom visual I think that requires dates, not text. The "Yesterday" text method only works if you're using a standard slicer.

shilpib Regular Visitor
Regular Visitor

Re: Timeline slicer default to previous day

I solved it by creating an extra slicer and getting 2 valyes there 1) yesterday and 2) all and set it to yetserday as default.