Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
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
kunkumnaveen
Specialist
Specialist
Author

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

sunny_talwar

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)

)
kunkumnaveen
Specialist
Specialist
Author

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)
)

sunny_talwar

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

kunkumnaveen
Specialist
Specialist
Author

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 ...

sunny_talwar

Sounds good.

kunkumnaveen
Specialist
Specialist
Author

Hello Sunny,

As requested ,please find the attached sample QVF file 

sunny_talwar

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)
)

 

kunkumnaveen
Specialist
Specialist
Author

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......

kunkumnaveen
Specialist
Specialist
Author

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