Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
marioxp
Contributor II
Contributor II

How to count the number of occurrences if the average is x ?

I need to count how many times there is an article whose "view" for a given month's statistics for "2019-09-01" and for a given month of publication "2019-09-01" meets the condition of the average number of "views" for an article for the period up to "2019-09-01"

 

The average for one article is = 653.8333333
The result should be 1

 

Variable "avg_view " 

=sum({<datastart={"$(= '<=' &date(Monthend(Now(),-1),'YYYY-MM-DD') )"}>} view)
/
count(distinct {<publishedAt={"$(= '<=' &date(Monthend(Now(),-1),'YYYY-MM-DD') )"} >} title)

clipboard_image_0.png

I know I should use count (AGGR ()) but I can not help it, can you help?

Labels (1)
8 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Can you provide a sample app?

marioxp
Contributor II
Contributor II
Author

Sample app attached

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

In your test table, add a new expression like this:

sum({<view={">=$(avg_view)"}>}view)

 

clipboard_image_0.png

marioxp
Contributor II
Contributor II
Author

If I want to show data for a given period 01-09-2019, not in the table only as a text field

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Do you mean like this?

clipboard_image_0.png

Expression in the textbox:

=count(aggr(sum({<view={">=$(avg_view)"}>}view),title))

marioxp
Contributor II
Contributor II
Author

More or less

In this case, it is about showing the meter for the sum of the given month in this case 09-2019.

I tried to modify what you showed but something is not working yet

=count(
aggr(
sum(
{<view={"<=$(avg_view)"},
[Month stat]={"$(= '>=' & Date(Monthstart(Now()),'YYYY-MM-DD') & '<=' &
Date(monthend(Now()),'YYYY-MM-DD'))"}>}
view)
,title))

I tried it this way

=count(
aggr(
if(
sum(
{<
[Month stat]={"$(= '>=' & Date(Monthstart(Now()),'YYYY-MM-DD') & '<=' &
Date(monthend(Now()),'YYYY-MM-DD'))"}>}
view )>=avg_view
,1,0)

,title)

I am still wondering how to show which article did not meet the total for the last 3 months.
I also don't want to work

=count(
aggr(
sum(
{<
view={"<=$(avg_view)"},
[Month stat]={"$(= '>=' & Date(Monthstart(Now(),-3),'YYYY-MM-DD') & '<=' &
Date(monthend(Now()),'YYYY-MM-DD'))"}

>}
view)
,title))

sunny_talwar

So, based on the data provided... what is the count you are expecting to see for 09-2019? and count for last 3 months?

Brett_Bleess
Former Employee
Former Employee

Mariusz, did you get things sorted?  If so, please consider leaving your solution in a new post on this thread, once posted, you can use the Accept as Solution button to mark it as well to let everyone know that is what worked.  If you can reply to Sunny's comment if you are still working upon things, he or someone else may be able to provide further help on things.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.