Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression help

Hi All,

Need help on expression:

I have a date calendar, I want to show Selected Month and Year in two text boxes. Conditions are as below:

  1. If there is no selection of Year, Month, Day (Default to Current year, Current month in the test boxes)
  2. If Year only selected and that is Lessthan current year, show DEC month & Selected Year in boxes.

          e.g. 2013 selected, show DEC & 2013

    3. If Year only selected and that is Current year default to Current month & current year in boxes.

            e.g. 2014 selected, show Sept & 2014

    4. If Year, Month selected – show as selected in boxes.

    5. If Day only selected, show the current month and current year in boxes.

    6. If month only selected, show current year and current month.

Can anybody help?

Thanks,

Lakshmi.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

=IF(GetSelectedCount([Invoice Date]) > 0 ,Month([Invoice Date]),

  IF(GetSelectedCount(Year) = 0 and GetSelectedCount(Month) = 0, Month(Today()),

  IF(GetSelectedCount(Year) > 0 and GetSelectedCount(Year) = Year(Today()), Month(Today()),

  IF(GetSelectedCount(Year) > 0 and GetSelectedCount(Year) < Year(Today()), SubField('$(MonthNames)',';',Max(Month))))))

View solution in original post

13 Replies
MK_QSL
MVP
MVP

=IF(GetSelectedCount([Invoice Date]) > 0 ,Month([Invoice Date]) & ' ' & Year([Invoice Date]),

  IF(GetFieldSelections(Year)<Year(Today()),SubField('$(MonthNames)',';',Max(Month)) & ' ' & Year, Month(Today()) & ' ' & Year(Today())))

Chagne [Invoice Date] to your DateFieldName

MayilVahanan

HI

Try like this

1. = 'Year: ' & if(GetSelectedCount(Day) <> 0 and getselectedcount(Year) = 0, Year(Today()), if(GetSelectedCount(Year) = 0, Year(Today()), Max(Year)) )

2. = 'Month: ' & if(GetSelectedCount(Day) <> 0 and getselectedcount(Month) = 0, Month(Today()), if(Max(Year) = Year(Today()), Month(Today()), Max(Month)) )

Thanks & Regards,
Mayil Vahanan R
Not applicable
Author

Hi Mayil,

When i choose month showing wrong. when i select 2014, april - showing 2014 - Sept.

Other years are OK.

MK_QSL
MVP
MVP

Sorry, I realised that you want two different text box ... use this...

=IF(GetSelectedCount([Invoice Date]) > 0 ,Month([Invoice Date]),

  IF(GetFieldSelections(Year)<Year(Today()),SubField('$(MonthNames)',';',Max(Month)), Month(Today())))

=IF(GetSelectedCount([Invoice Date]) > 0 ,Year([Invoice Date]),

  IF(GetFieldSelections(Year)<Year(Today()),Year,Year(Today())))

MayilVahanan

Hi

Above combination u didn't mention ..

For that, month will display "Dec" ? If so,

Try like this

= 'Month: ' & if(GetSelectedCount(Day) <> 0 and getselectedcount(Month) = 0 and getselectedCount(Year) = 0, Month(Today()), if(Max(Year) = Year(Today()), Month(Today()), Max(Month)) )

Thanks & Regards,
Mayil Vahanan R
Not applicable
Author

Hi Manish & Mayil,

Thanks for help. both conditions are working except if i choose 2014 & Month. all time taking Sept - 2014.

MK_QSL
MVP
MVP

=IF(GetSelectedCount([Invoice Date]) > 0 ,Month([Invoice Date]),

  IF(GetFieldSelections(Month) <> 0,

  IF(GetFieldSelections(Year)<Year(Today()),SubField('$(MonthNames)',';',Max(Month)), Month),

  Month(Today())))

and

=IF(GetSelectedCount([Invoice Date]) > 0 ,Year([Invoice Date]),

  IF(GetFieldSelections(Year)<Year(Today()),Year,Year(Today())))

Not applicable
Author

Hi Manish & Mayil,

Thanks for help. both conditions are working except if i choose 2014 & Month. all time taking Sept - 2014.

Not applicable
Author

Hi Manish,

If i dont choose anything month is blank, else everything working.