Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis - Error trying to get prior year

I have this formula that gives me some result based on some criteria, including the selected Year. This works fine.

Count({$ <P_STATUS={'A'}, TOTAL_CHARGE = {">0"}, TRN_CODE = {0}, Year_DOS = {$(=Only(Year_DOS))} >} Distinct LFN_NO)

In a different column I want to do the same for the prior year, so I changed the formula a little bit. This is not working, it gives me zero as result for all dimensions.

Count({$ <P_STATUS={'A'}, TOTAL_CHARGE = {">0"}, TRN_CODE = {0}, Year_DOS = {$(=Only(Year_DOS)-1)} >} Distinct LFN_NO)

What am I doing wrong?

Thanks in advance for your help.

2 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

What you doing seems correct. It works for me. May be something is wrong with your field type for the year field. Are you taking year out of a date field in your data model? Is it a text field? You can put that field on the document and see (based on right, left justification) if it is somehow considered a text field. Or may be something wrong with you dimensions. The formula you are using is correct and worked for my test document (enclosed).

Hope this helps.

Not applicable
Author

I am getting the year out of a date field from my data model. Interesting if I do a -0 it works, the problem is with the -1