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

How to show my data always to be MTD and YTD

Hi, now my practice is when a start new month, i will go and select my qvw. file choose the latest month and save it.

Is there anyway i can show my data always with latest month to date and year to date.

The data file i have is from 2015 till date.

1 Solution

Accepted Solutions
Mark_Little
Luminary
Luminary

Hi,

For this can of thing i always create flags within my calendar in the script. That way it makes the set analysis easier and updates with every load

Something like this

IF(YEAR(TempDate)= YEAR(TODAY(1)) AND TempDate <= TODAY(1),1) AS F_CAL_YTD,

IF(YEAR(TempDate)= YEAR(TODAY(1)) AND MONTH(TempDate)= MONTH(TODAY(1)) AND TempDate <= TODAY(1),1) AS F_MTD,

Then Set analysis would be

SUM({<F_CAL_YTD={1}>}Values)

Mark

View solution in original post

7 Replies
Anil_Babu_Samineni

Yes, You can define many ways for MTD / YTD. Can you share logic what you need?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Mark_Little
Luminary
Luminary

Hi,

For this can of thing i always create flags within my calendar in the script. That way it makes the set analysis easier and updates with every load

Something like this

IF(YEAR(TempDate)= YEAR(TODAY(1)) AND TempDate <= TODAY(1),1) AS F_CAL_YTD,

IF(YEAR(TempDate)= YEAR(TODAY(1)) AND MONTH(TempDate)= MONTH(TODAY(1)) AND TempDate <= TODAY(1),1) AS F_MTD,

Then Set analysis would be

SUM({<F_CAL_YTD={1}>}Values)

Mark

prabunakil
Contributor III
Contributor III
Author

Hi mark, this will be in load script or dimension of the field?

prabunakil
Contributor III
Contributor III
Author

Please check how i define my month and year.

Right(DAT,2) as TransactionDay,

Mid(DAT,6,2) as TransactionMonth,

Left(DAT,4) as TransactionYear,  

if(num(Mid(DAT,6,2))<=3, Left(DAT,4)-1 & '/' & Left(DAT,4), Left(DAT,4) & '/' & text(Left(DAT,4)+1)) AS [Fiscal Year],

Mark_Little
Luminary
Luminary

Hi,

It will created new fields within your data, The fields will contain a 1 when they match the criteria. For example any date that is in the current MTD the field F_MTD will contain a 1.

This can then be referenced in the Set analysis.


Mark

prabunakil
Contributor III
Contributor III
Author

Hi Can i have a example of the qvw.

prabunakil
Contributor III
Contributor III
Author

thank you it works.