Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Manel222
Contributor II
Contributor II

month according to start date and end date

Hello Guys,

I have a bar chart that displayes the number of products of the two last months,

dimension :

=valuelist(
  monthname(monthstart(today(),0)),
  monthname(monthstart(today(),-1)),
    monthname(monthstart(today(),-2)),
    monthname(monthstart(today(),-3)),
    monthname(monthstart(today(),-4)),
    monthname(monthstart(today(),-5)),
    monthname(monthstart(today(),-6)),
    monthname(monthstart(today(),-7)),
    monthname(monthstart(today(),-8)),
    monthname(monthstart(today(),-9)),
    monthname(monthstart(today(),-10)),
    monthname(monthstart(today(),-11)),
    monthname(monthstart(today(),-12))
    ) 

measure :

IF(
valuelist(
  monthname(monthstart(today(),0)),
  monthname(monthstart(today(),-1)),
    monthname(monthstart(today(),-2)),
    monthname(monthstart(today(),-3)),
    monthname(monthstart(today(),-4)),
    monthname(monthstart(today(),-5)),
    monthname(monthstart(today(),-6)),
    monthname(monthstart(today(),-7)),
    monthname(monthstart(today(),-8)),
    monthname(monthstart(today(),-9)),
    monthname(monthstart(today(),-10)),
    monthname(monthstart(today(),-11)),
    monthname(monthstart(today(),-12)) 
    )=monthname(monthstart(today(),0))

 

,Count(Distinct{<date_entre={"<=$(=date(monthend(today(),-1)))"}, flag_max_date={"$(=IF(getselectedcount(test)=0,'*','1'))"} >} product )) 
,
IF(
valuelist(
  monthname(monthstart(today(),0)),
  monthname(monthstart(today(),-1)),
    monthname(monthstart(today(),-2)),
    monthname(monthstart(today(),-3)),
    monthname(monthstart(today(),-4)),
    monthname(monthstart(today(),-5)),
    monthname(monthstart(today(),-6)),
    monthname(monthstart(today(),-7)),
    monthname(monthstart(today(),-8)),
    monthname(monthstart(today(),-9)),
    monthname(monthstart(today(),-10)),
    monthname(monthstart(today(),-11)),
    monthname(monthstart(today(),-12))
    )=monthname(monthstart(today(),-1))

 

,Count(Distinct{<date_entre={"<=$(=date(monthend(today(),-1)))"}, flag_max_date={"$(=IF(getselectedcount(test)=0,'*','1'))"} >} product ))
)

 

I need that the mothes displayed in the bar chart depends of the variable start date and end date

Labels (1)
1 Reply
marksouzacosta

Hi @Manel222,

Sorry to say but I think you got a bad path to solve this problem.
When your dimensions and expressions look too complex, that indicates an opportunity to improvements in your Load Script. So, every time that happens, try to move things to the Load Script.

The very first thing I think you need to do is to create a calendar table for your application based on date_entre field. This will eliminate most of the complexity of your expressions. There is an excellent article about that here: https://qlikviewcookbook.com/2015/05/better-calendar-scripts/

That is your start point. Let us know about your progress on this and then we can move to the next steps.

 

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net