Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

apoorvasd
Contributor II

Dynamic Labels for bar chart

Hello Everyone,

I would like to have a dynamic labels for my chart. What I mean is, when I select a week or a month which is less than current month, then the label should display, "Thereof BB" and if the month or week selected is greater than or equal to current month then the label of the bar should display ,"Risk BB" . With the below mentioned expression I am getting to work this except that, when I select more than one past or future month, it is not working.

=if(GetFieldSelections(WeekShort)>=month(Date#(WeekShort,'MMM')) or  Month(Date#(POPER_NEW, 'MMM'))>=month(today()) 

,'Risk BB'  ,if(GetFieldSelections(WeekShort)<month(Date#(WeekShort,'MMM')) or Month(Date#(POPER_NEW, 'MMM'))<month(today())  ,'Thereof BB', 'Thereof BB'))

Any help on this?

Thank you.

1 Solution

Accepted Solutions
MVP
MVP

Re: Dynamic Labels for bar chart

This?

=If(GetSelectedCount(WeekShort) OR  GetSelectedCount(POPER_NEW), If(Max(WeekShort)<MonthStart(Today()), 'Thereof BB','Risk BB'), 'Your Suitable message')

15 Replies
MVP
MVP

Re: Dynamic Labels for bar chart

I think the GetFieldSelections() is probably the part that creates the issue for you.

But I don't understand this part really, why are you comparing WeekShort selections to WeekShort?

Is this the field you are making selections in? And are you using one of these fields as dimension in your chart?

A small sample might help to understand your issue.

apoorvasd
Contributor II

Re: Dynamic Labels for bar chart

Hi Stefan,

Yes, WeekShort is the field in which selections can be made which has date as its values. Based on the date that a user selects in this field it should check if the date belongs to current or past months, that's the reason i have provided that condition.

I have attached sample files.

Thank you.

MVP
MVP

Re: Dynamic Labels for bar chart

Given your sample QVW, what do you expect to see when you do some selections in WeekShort (for example, when selecting Oct in POPER_NEW, what should I select in WeekShort? And what do you expect to see in your chart?)?

Looking at this part or your label expression

GetFieldSelections(WeekShort)>=month(Date#(WeekShort,'MMM'))


Why are you using the month() function on your WeekShort date (and why are you using Date#() interpretation here, and in addition why with an incompatible format code?)?


I don't really understand what you are trying to do here.

apoorvasd
Contributor II

Re: Dynamic Labels for bar chart

GetFieldSelections(WeekShort)>=month(Date#(WeekShort,'MMM'))


In this expression, I am just trying to check if the month in the selected WeekShort is greater than or equal to current Month.

So when there is a selection made in WeekShort, it should check which month it belongs to and based on that the label of the bar graph should change. Ignore the expression for the bars, i want a solution for labels. I think I have explained what I want in my original post. Hope you can help me!

Thanks.

MVP
MVP

Re: Dynamic Labels for bar chart

I've understood you are looking at the label expression.

But where in

GetFieldSelections(WeekShort)>=month(Date#(WeekShort,'MMM'))

are you checking against current month?

apoorvasd
Contributor II

Re: Dynamic Labels for bar chart

Current and future months

MVP
MVP

Re: Dynamic Labels for bar chart

Seems like we have an ongoing communication problem, sorry for that. I am out of this discussion.

Just some general hints:

- WeekShort is already a date value. No need to interpret it using Date#().

- Month(WeekShort) is returning the unique month of the unique date value as a single dual value (text and number)

- If you select more than one WeekShort value from different months, Month(WeekShort) will return NULL

- GetFieldSelections() will return a comma separated string of the dates and you are comparing this to a single month value

apoorvasd
Contributor II

Re: Dynamic Labels for bar chart

Okay, thanks for those hints Stefan!

I will look into them.

MVP
MVP

Re: Dynamic Labels for bar chart

May be this?

=If(GetSelectedCount(WeekShort), If(Max(WeekShort)<MonthStart(Today()), 'Thereof BB','Risk BB'), 'No WeekShort is Selected')

Community Browser