Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
markp201
Creator III
Creator III

Avg birth year for selected years...

We have the following set analysis

avg({<{birthyear={">1960"}>}birthyear)

or

avg({<birthyear={"<2000>1960"}>}birthyear)

Birth year is in a dimension table with associated facts.

I've been verifying the results and the avg is off.

Can set analysis use the same field for dimension and measure?

1 Solution

Accepted Solutions
MarcoWedel

Hi,

your expression should work.

QlikCommunity_Thread_245927_Pic1.JPG

QlikCommunity_Thread_245927_Pic2.JPG

QlikCommunity_Thread_245927_Pic3.JPG

Can you post a sample where it does not work?

Maybe you expect different results because your bithyear field is shared between your dimension and fact tables having different numbers of occurrences in both or you mean to calculate some average of distinct birthyears avg(distinct birthyear)?

thanks

regards

Marco

View solution in original post

7 Replies
krishnacbe
Partner - Specialist III
Partner - Specialist III

Hi,

Set Analysis can  use Same field for Dimension and measure.

But this scenario it wont give any result.

What measure you want to identify using this expression. Elaborate your requirement.

markp201
Creator III
Creator III
Author

on average, what is the birth year of individuals born between 1960 and 2000

krishnacbe
Partner - Specialist III
Partner - Specialist III

Ok.

You should be having a field for addressing individual row like PersonId/Row ID.

avg({<{birthyear={">1960"}>}PersonID)

krishnacbe
Partner - Specialist III
Partner - Specialist III

Share the Table structure or sample data to dig more and find the exact expression

MarcoWedel

Hi,

your expression should work.

QlikCommunity_Thread_245927_Pic1.JPG

QlikCommunity_Thread_245927_Pic2.JPG

QlikCommunity_Thread_245927_Pic3.JPG

Can you post a sample where it does not work?

Maybe you expect different results because your bithyear field is shared between your dimension and fact tables having different numbers of occurrences in both or you mean to calculate some average of distinct birthyears avg(distinct birthyear)?

thanks

regards

Marco

markp201
Creator III
Creator III
Author

I'm thinking that's the problem.  The year is in the dimension, not the fact so any averaging is ignoring the detail.

We'll have to modify the script to attach birth year to the detail

Thanks

MarcoWedel

Please close your thread if your question is answered:

Qlik Community Tip: Marking Replies as Correct or Helpful

thanks

regards

Marco