Skip to main content

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
pratap6699
Creator
Creator

By using if condition, 2 expressions will displayed based on date selections in qlik sense

Hi Experts,

Hope you are all good.

I need your help that, i have faced one visualization issue with BAR chart object in qlik. My requirement is when user select date from [Created Date] field, then One Expression will displayed, ELSE second expression should displayed. 

EX:  20JUN2029 date selected from [Created Date] field, then sales displayed from 01JAN2019 to 20JUN2019 date range as specified "WITHSELECTION" screenshot, if user doesnot select any Date by default, Current year start date to Till date SALES should displayed as specified "WITHOUTSELECTION" screenshot. for this requirement i have used [Year Month] as dimension and   EXPRESSION is 

If(GetSelectedCount([Created Date]) >= 1,
Count({<[Created Date] = {">=$(vSelectedDateYearStart)<=$(vSelectedPreviousDate)"}>}SALES),
Count({<[Created Date] = {">=$(vSelectedDateYearStart)<=$(vSelectedYearStart)"}>}SALES))     . 

My issue is without any date selection current year start to till date BARS only should displayed, but in BAR chart displaying from data loaded dates(2018 to tilldates data) is showing in X-Axis, iam expecting only current year data.

when i apply TRUE expression(withselection) & FALSE expression (withoutselection) BARS and data are coming perfect. when used above IF() condition (withselection) data coming as expected, but (withoutselection) not working as expected(current year to till date).

Can any one help me to fix this issue... 

Many Thanks in advance....

Thanks,

pratap

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

Did you try creating variables as I have suggested  and then expression suggested in previous reply? This should work as expected if not then using your expression  go to bar properties->Add-On->Data handling-> Uncheck Include zero value

View solution in original post

4 Replies
Kushal_Chawda

No Need to write the if condition for this. You can achieve it using single expression

Create variable on front end like below

vSelectedDateYearStart 

=  yearstart(max([Created Date]))

vSelectedDateYearEnd

=  max([Created Date])

Then you can simply use below expression

Count({<[Created Date] = {">=$(vSelectedDateYearStart)<=$(vSelectedDateYearEnd)"}>}SALES)

pratap6699
Creator
Creator
Author

 Hi Kush,

Thanks for your quick response.

your logic won't work, why because,

Count({<[Created Date] = {">=$(vSelectedDateYearStart)<=$(vSelectedDateYearEnd)"}>}SALES)

here, without select anything data showing from 01JAN2018(vSelectedDateYearStart) to till date(vSelectedDateYearEnd), please find the screenshot(Not working). 

My requirement is there is 2018 to 2010 July data, when user select 16Jun2019 then need to display 01Jan2019 to 16Jun2019 data, if not select anything, only current year starting 01Jan2020 to Till Dates data should show....

 

 

Kushal_Chawda

Did you try creating variables as I have suggested  and then expression suggested in previous reply? This should work as expected if not then using your expression  go to bar properties->Add-On->Data handling-> Uncheck Include zero value

pratap6699
Creator
Creator
Author

Hi Kush,

Thanks for your efforts.

My Expression works fine, but i missed that property AddOns-->Datamodel-->Include ZeroValues(UNCHECK)..

Thanks for your suggestion, it's working exactly, what i expected.

Thanks,

Pratap