Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist
Specialist

How to write condition enabling in expression

Hello All,

i Need help in doing a condition enabling in a chart , in below combo chart by default i have to show as below

Dimension: YEARMONTH

Expression: 1)Prod:    Sum({<Month,Year,Date={">=$(=date(monthstart(addmonths(max(Date),-5)),'DD-MM-YYYY'))<=$(=date(((max(Date))),'DD-MM-YYYY'))"}>}p_input)

                        2)Sale:      Sum({<Month,Year,Date={">=$(=date(monthstart(addmonths(max(Date),-5)),'DD-MM-YYYY'))<=$(=date(((max(Date))),'DD-MM-YYYY'))"}>}p_d_op)

Combo:  

Untitled.png

 

so far so good,

Now my requirement is to do a condition enabling , I have created a inline field called Category which as values prod,sale,Brand and in each expression i have added condition as shown below

Combo Chart:

Dimension: YEARMONTH

EXpression :1)   if(Getselectedcount(Category) =0 or Category='prod',

Sum({<Month,Year,Date={">=$(=date(monthstart(addmonths(max(Date),-5)),'DD-MM-YYYY'))<=$(=date(((max(Date))),'DD-MM-YYYY'))"}>}p_input)

)

 

Before selecting Category 

Untit.png

 

 

After selecting  prod from category

Untitled1.png

 

 

I am getting only Selected Year, Month prod values even after ignoring Year,Month

Kindly suggest,how to write condition in expression.

 

Thanks

 

  

         

Labels (2)
28 Replies
Highlighted
Specialist
Specialist

I am getting error either i select prod or sale or both from Category

Highlighted

Can you try adding TOTAL within the Only() function also

If(GetSelectedCount(Category) = 0 or Only({1} TOTAL Category) = 'prod',

Sum({<Month,Year,Date={">=$(=Date(MonthStart(Max(Date), -5), 'DD-MM-YYYY'))<=$(=Date(Max(Date), 'DD-MM-YYYY'))"}>} p_input)

)
Highlighted
Specialist
Specialist

When i slight change the expression, i am able to see the chart but only for selected Year,Month(2019 ,dec) .

the drawback of this expression is it not ignoring Year,Month

If(GetSelectedCount(Category) = 0 or Category='sale',

Sum({<Month,Year,Date={">=$(=date(monthstart(addmonths(max(Date),-5)),'DD-MM-YYYY'))<=$(=date(((max(Date))),'DD-MM-YYYY'))"}>}p_d_OP)
)

Highlighted

Would you be able to share a qvf sample to show the issue?

Highlighted
Specialist
Specialist

HI,

the file is in the server , which i have no access .....what i do is i will create a qvf with some dummy data in my desktop and will share the qvf  in 30 min ...

Highlighted

Sounds good.

Highlighted
Specialist
Specialist

Hello Sunny,

As requested ,please find the attached sample QVF file 

Highlighted

It was my bad all along... try this

 

If(GetSelectedCount(Category)=0 or Only({1<Category = p(Category)>} Category) = 'prod',
	Sum({<Month, Year, Date = {">=$(=Date(MonthStart(Max(Date),-5), 'DD-MM-YYYY'))<=$(=Date(Max(Date), 'DD-MM-YYYY'))"}>} p_input)
)

 

Highlighted
Specialist
Specialist

Hello Sunny, thanks for your concern  and sorry for annoying you.

I still find two issues in the file you have shared 

1) If there is Year and Month selection , the chart is showing only the selected Year,Month bar or Line.In fact it suppose to bypass the Year and Month Selection(It is working if no year and Month is selected)

2)IF i select both prod and sale , the chart is showing error . In real time data i have 5 different values in category so which means there will be five expression.

so user need flexibility to chose either one or two or three or more values from category......

Highlighted
Specialist
Specialist

Hello 

Screen1(No Year and Month selection only Category='prod')

Untitled.png

Screen2( Year and Month selected and  Category='prod')

Untitled1.png

Screen1(Year and Month selection and  Category='prod' and Category='sale')

 

Untitled2.png