Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
What will be the expression if I want to get the FY? May date format is DD/MM/YYYY.
Thanks a lot.
Br,
Kenji
Hi,
Step 1: Create Fiscal year using following script:
https://community.qlik.com/t5/App-Development/Master-Calender/m-p/1883271#M72729
Step 2: Show Sales for current fiscal year
sum( {< Fiscalyear = { "$(=max(FiscalYear)) " } >} Sales)
Previous Year
sum( {< Fiscalyear = { "$(=max(FiscalYear)-1) " } >} Sales)
Hope this help you.
Thanks
Vikas
Hi Vikasmahajan,
Thanks for the prompt response. The expression computes but it is short of the expectations.
I filtered the year to 2022 and should be getting FY21 results.
The result is the same for both (previous & current) expressions. What could be the issue? Thank you
Hi,
Please check with date is linked properly :
also refer this link for details set analysis period
Thanks
Vikas
can you share sample data
Vikas
Hi Kenji,
I suspect that you haven't created a FiscalYear column, rather that you are using the native calendar year, so your Max function is only returning the Max calendar year of 2022.
What @vikasmahajan is saying is that once you create a column in the script that is calculated from your date column and returns the fiscal year (eg: Starting in July), you'll be able to use the expression he has supplied above to return those values.
For example:
In your script you create a column using something like below (Assuming the fiscal year begins in July):
Data:
load
*,
if(month([Date]) < 7,
Year([Date])-1, Year([Date])) as FiscalYear
From YourDataFile.QVD;
This will return a numeric value. Using 28/02/2022 as an example would return: 21
Once the date goes past 01/07/2022 the FiscalYear will return: 22
Assuming you don't have any future dates in your data the Max function currently will return 21 for all records where [Date] is greater than 30/06/2021.
I hope this helps Kenji and that I have assumed your response correctly @vikasmahajan .
Thank you
Anthony
Thanks a lot @anthonyj and @vikasmahajan . 🙂 I will work on this later and give you feedback. 🙂