# Finding and using first values

**URL:** <https://community.amazonquick.com/t/finding-and-using-first-values/29677>\
**Category:** Q&A\
**Tags:** analysis, calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [May 10, 2024, 11:29pm UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677 "2024-05-10T23:29:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjk](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tjk](https://community.amazonquick.com/u/tjk)\
**Post date:** [May 10, 2024, 11:29pm UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677/1 "2024-05-10T23:29:09Z")

</div>

Let’s say I have a dataset that looks like this:

| user\_email | order\_timestamp | order\_amount | marketing\_channel |
| --- | --- | --- | --- |
| [bart@email.com](mailto:bart@email.com) | 3/4/24 | 3 | email |
| [bart@email.com](mailto:bart@email.com) | 3/3/24 | 5 | ads |
| [john@email.com](mailto:john@email.com) | 1/1/24 | 2 | sms |
| [john@email.com](mailto:john@email.com) | 1/2/24 | 4 | push |
| [john@email.com](mailto:john@email.com) | 1/3/24 | 3 | push |
| [mila@email.com](mailto:mila@email.com) | 3/5/24 | 5 | ads |
| [mila@email.com](mailto:mila@email.com) | 3/3/24 | 3 | email |

I was able to build a cohort analysis using the timestamp with “minOver” function with PRE\_FILTER aggregation. So I now have “first\_order\_date” available.  
But what I aslo need is “first\_marketing\_channel” value on each record, so that I can filter my cohort analysis by it.  
E.g. I want to see LTV (sum of order amounts regardless of marketing channels) for users who came the very first time from a specific marketing channel. I was hoping to use fistValue, but it doesn’t support PRE\_FILTER.

---

<div class="post-metadata">

**Author:** ![David\_Wong](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/david_wong/32/15630_2.png) [@David\_Wong](https://community.amazonquick.com/u/David_Wong)\
**Post date:** [May 11, 2024, 7:08pm UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677/2 "2024-05-11T19:08:05Z")

</div>

Hi @tjk,

You can try to use the rank function with PRE\_FILTER and then filter by rank = 1.

---

<div class="post-metadata">

**Author:** ![tjk](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tjk](https://community.amazonquick.com/u/tjk)\
**Post date:** [May 11, 2024, 9:34pm UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677/3 "2024-05-11T21:34:31Z")

</div>

Already tried that. Problem is - if I use rank as a filter, I won’t get LTV calculation for all orders. It will be limited to first order only.

I need a way for every record to have an additional column that is “initial\_marketing\_channel”

---

<div class="post-metadata">

**Author:** ![David\_Wong](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/david_wong/32/15630_2.png) [@David\_Wong](https://community.amazonquick.com/u/David_Wong)\
**Post date:** [May 20, 2024, 5:43am UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677/4 "2024-05-20T05:43:03Z")

</div>

Are you trying to create a visual like this?  
 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/2/5/25cb308267598444f4bce932edaf4bc99552f38b.png)

Do you need to filter your visual by date or marketing channel?

---

<div class="post-metadata">

**Author:** ![tjk](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tjk](https://community.amazonquick.com/u/tjk)\
**Post date:** [May 20, 2024, 5:23pm UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677/5 "2024-05-20T17:23:28Z")

</div>

The visual you did I think I know how to create, but I need something a bit harder. I need those “first\_order"date” and “initial\_marketing\_channel” to be next to every record in the dataset, because this will allow me to build a cohort analysis that will look smth like this (with ability to filter by initial marketing channel):

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/9/a/9ae34a28aa217dd6aee4acbb75b7395647e80eaf.png)

Intersections show LTV, which is the sum of order\_amount divided by initial cohort size.

---

<div class="post-metadata">

**Author:** ![David\_Wong](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/david_wong/32/15630_2.png) [@David\_Wong](https://community.amazonquick.com/u/David_Wong)\
**Post date:** [May 21, 2024, 1:55am UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677/6 "2024-05-21T01:55:25Z")

</div>

I think your best bet is to use SQL to calculate your initial marketing channel at the dataset level.

---

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [May 21, 2024, 3:41am UTC](https://community.amazonquick.com/t/finding-and-using-first-values/29677/7 "2024-05-21T03:41:34Z")

</div>

Did this solution work for you? I am marking this reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the Quick Sight Community!
