Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
AnnaEKinch
Partner - Contributor III
Partner - Contributor III

Number of months between latest data date and the beginning of the year

Hi!

I want to divide a sum by the number of months of data that I have in the model.

So in September I have data in my model for Jan-August 2020 so I want to divide a sum by 8.

=Sum({<[DataType]={'Actual'}, YTDFlag={1}>}[Price (SEK)])/Count( distinct [User Id - User])/8

 

In October, the september data comes in, so then I want to divide my sum by 9.

=Sum({<[DataType]={'Actual'}, YTDFlag={1}>}[Price (SEK)])/Count( distinct [User Id - User])/9

 

How can I make an automatic calculation the number of months of data that I have in my model?

 

I am grateful firstly for help with the automation of months and if possible also help with the formula....as I am new maybe I have made a mistake in my formula as well 🙂 (although it seems to work).

Thanks,

Anna.

Labels (1)
1 Solution

Accepted Solutions
AnnaEKinch
Partner - Contributor III
Partner - Contributor III
Author

Thanks so much Anil_Babu_Samineni, I worked out that I could use GetSelectedCount for "Period" and if I have nothing selected then I used Max([Month]). Thanks anyway 🙂

 

View solution in original post

2 Replies
Anil_Babu_Samineni

May be

Count({<DateField={">=$(=YearStart(Max(DateField)))<=$(=Max(DateField))"}>} TOTAL MonthField)

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
AnnaEKinch
Partner - Contributor III
Partner - Contributor III
Author

Thanks so much Anil_Babu_Samineni, I worked out that I could use GetSelectedCount for "Period" and if I have nothing selected then I used Max([Month]). Thanks anyway 🙂