Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
george55
Partner - Creator III
Partner - Creator III

Date-Filterbox not working - Invalid dimension

Hi all,

Would like to use a Date-Filterbox with a dimension containing timestamps (DATEFIELD1). When I use this formula, it works:

If(DATEFIELD1 > Today()-3), '-3 Days')

but with this formula not (got an invalid dimension):

If(DATEFIELD1 > FirstWorkDate(Max(Floor(DATEFIELD1)), 3, $(Holiday)), '-3 Days')

Below you can see the different datatypeformats:

Formula / FieldNum (Zahl)ZahlDatumDauerAutomatisch
Max(DATEFIELD1)43857.3843857.3827.01.20201052577:11:0727.01.2020 09:11
FirstWorkDate(Max(Floor(DATEFIELD1)), 5, $(Holiday))43851.0043851.0021.01.20201052424:00:0021.01.2020
Today()-143857.0043857.0027.01.202027.01.202043857

 

Previously thought there is a datatype-issue. Tried many converting-variations but with no success. Also when I'm doing a simple calculation, the result is a valid number: 

Max(DATEFIELD1) - FirstWorkDate(Max(Floor(DATEFIELD1)), 5, $(Holiday))

So I'm now confused and don't know what else to do. 

Thanks for any helpful information.

George

Labels (1)
  • SaaS

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try this: If(DATEFIELD1 > FirstWorkDate($(=Max(Floor(DATEFIELD1))), 3, $(Holiday)), '-3 Days')


talk is cheap, supply exceeds demand

View solution in original post

7 Replies
Gysbert_Wassenaar

Try this: If(DATEFIELD1 > FirstWorkDate($(=Max(Floor(DATEFIELD1))), 3, $(Holiday)), '-3 Days')


talk is cheap, supply exceeds demand
george55
Partner - Creator III
Partner - Creator III
Author

Thanks Gysbert, it worked!

Can you explain what the idea is behind this aspect? Thank you again.

Gysbert_Wassenaar

In a filter pane you either need to calculate the max date outside the context of the object or you need to use the aggr function so you get a result value for each dimension value of the dimension you use in the filter pane. In this case the first option is the correct solution. By using the $(=...expression..) syntax the max date is calculated at the document level instead of being evaluated (and failing in this case) at the row level of the filter pane dimension.


talk is cheap, supply exceeds demand
george55
Partner - Creator III
Partner - Creator III
Author

thought something simliar it has to be with the different "levels" of data (document type). Was just confused why it worked with Today(). So that means if only use a function like Today(), I stay on same level (context of the object)?

Gysbert_Wassenaar

Today() just returns today's date. It doesn't use any dimension values to calculate the result.


talk is cheap, supply exceeds demand
george55
Partner - Creator III
Partner - Creator III
Author

I do now have the next issue. May be is better to open new Thread here?

The filter pane is working fine, and the weekenddays are excluded, but not the associated dimensions. the dimensions have still the weekend inkluded.

Sure I could exclude this in the load script, but want to avoid that, because in some situations it is usefull to have the weekend included.

Thanks for any further advice.

Gysbert_Wassenaar

A new thread is better. Better yet is searching first. Your problem has likely been solved already a couple of times. Sounds like perhaps creating a flag field for the dates that are in weekends would work:

if(WeekDay(DATEFIELD1)>5,1,0) as IsWeekend


talk is cheap, supply exceeds demand