Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Filter by Max(Date) in Set Analysis

Hi All!!

This it´s my first post

I have a textbox with the following expression=

if(getselectedcount (calend.month)=0,
sum({1<[DIM_MONEDA_ID] = {'USD'},common_date={'>=$(vMaxDate)'}, FIG.FACT_EST_TABLA_ORIGEN={'REAL'},FIG.DIM_ITEM_REPORTE_KEY={'CONTRIBUTION MARGIN'} >} FIG.FACT_EST_VALOR),
sum({1<[DIM_MONEDA_ID] = {'USD'},common_date=P(common_date),FIG.FACT_EST_TABLA_ORIGEN={'REAL'},FIG.DIM_ITEM_REPORTE_KEY={'CONTRIBUTION MARGIN'} >}
  if(common_date=$(vMaxDate),FIG.FACT_EST_VALOR)))

where :

calend.month = Month on master calendar

DIM_MONEDA_ID = Currency dimension, i'm filtering only by USD

common_date = master date in master calendar

FIG.FACT_EST_TABLA_ORIGEN = Always "REAL"

FIG.DIM_ITEM_REPORTE_KEY = Always "CONTRIBUTION MARGIN"

FIG.FACT_EST_VALOR = Field to be added in expression


The calend.month are filter by user. Texbox will be show only the max month selected when currency = USD, Tabla Origen = "Real" and ITEM_REPORTE_KEY = "CONTRIBUTION MARGIN". If the user haven't made selections, textbox shows the value of the last month charged.


I have the following behavior associated to month selections by users


- If the user haven't month selected, textbox shows correctly the sum(values) of last month.

- If the users have one month selected, textbox shows correctly the sum(values) of selected month

- If the users have 2 or more month selected, textbox shows the sum of all month selected.


I need to shows always the max(month) independent of month selections.


Any suggestion?


PS: Please apologies for my english.

1 Solution

Accepted Solutions
sunny_talwar

This one is even be better. PFA

Best,

S

View solution in original post

10 Replies
sunny_talwar

For max(month) regardless of selection you can use Max ({1} month). This will ignor any selections you make in your application.

Update: If it should not change only based on a selection in month, then you can use Max({<month = >} month)

Best,

S

Not applicable
Author

Thanks Suninidia for your prompt answer!.

Please excuse me if I didn't explain well.


I want to calculate the sum() of value when currency = USD, Tabla Origen = "Real" and ITEM_REPORTE_KEY = "CONTRIBUTION MARGIN" for max(month). If the user have made selections(1 month or more),the sum should be the maximum month related to user selection.


Could you have any suggestion to solve this?.


Thanks again!.

C.


sunny_talwar

Sorry about not interpreting you question correctly the first time.

Is your calend.month field a date field (Jan-2014) or is it Text(Jan, Feb, Mar...) ?

Best,

S

Not applicable
Author

Hi Sunindia,

There is my calend table. calend.month is a text field. For this reasons I'm using "common_date" field to manage date filters.

calend.yearcalend.monthcalend.quartercommon_date
2014janT101-01-2014
2014febT102-01-2014
2014marT103-01-2014
2014aprT204-01-2014
2014mayT205-01-2014
2014junT206-01-2014
2014julT307-01-2014
2014augT308-01-2014
2014sepT309-01-2014
2014octT410-01-2014
2014novT411-01-2014
2014decT412-01-2014
sunny_talwar

Update: you will need to do this in the script.

Is replacing calend.month to a date field a possibility?

If you use MonthName(common_date) as calend.month it will give you something like this Jan-2014, Feb-2014, Mar-2014... and so on.

This way you can use MaX(calend.month) directly in your set analysis.

Best,

S

Not applicable
Author

I'm applying your solution with no luck

I'm sharing a sample QVW file with data and formulas. Please review and fix it if possible.

Thanks!!

C.

sunny_talwar

See if this makes sense. PFA

Best,

S

sunny_talwar

This one is even be better. PFA

Best,

S

Not applicable
Author

I'ts work perfectly. You're save my day!.

Thanks you.

Christian.