Categories
- All Categories
- Oracle Analytics Learning Hub
- 20 Oracle Analytics Sharing Center
- 17 Oracle Analytics Lounge
- 233 Oracle Analytics News
- 45 Oracle Analytics Videos
- 15.9K Oracle Analytics Forums
- 6.2K Oracle Analytics Idea Labs
- Oracle Analytics User Groups
- 87 Oracle Analytics Trainings
- 15 Oracle Analytics Data Visualizations Challenge
- Find Partners
- For Partners
Pivot aggregates based on Stage name and year quarter using earliest Stage entry-multiple line items
Trying to create a pivot table which aggregates the lifetime value of the opportunity based on the following (using the earlies stage enter date)
1st: Per Sales Stage Name
2nd: Per Year Quarter (e.g. 2024 Q2)
Sample pivot table:
Sales Stage Name | 2024 Q1 | 2024 Q2 |
|---|---|---|
Stage 1 |
|
|
Stage 2 |
|
|
Stage 3 |
|
|
Sample Data:
Opportunity number | Sales Stage Name | Stage Enter Date | Stage Enter Quarter | Lifetime Value (USD) | Stage Progression Active Flag |
|---|---|---|---|---|---|
123 | Stage 1 | 1-Jan | 2024 Q1 | $ 200 | Y |
123 | Stage 2 | 1-Feb | 2024 Q1 | $ 300 | Y |
123 | Stage 3 | 1-Mar | 2024 Q1 | $ 400 | N |
123 | Stage 3 | 1-Apr | 2024 Q2 | $ 400 | Y |
456 | Stage 1 | 5-Feb | 2024 Q1 | $ 200 | Y |
456 | Stage 2 | 5-Mar | 2024 Q1 | $ 300 | N |
456 | Stage 2 | 5-Apr | 2024 Q2 | $ 300 | Y |
456 | Stage 3 | 15-May | 2024 Q2 | $ 400 | Y |
Pivot table result:
Opportunity number | 123 |
|
|
|---|---|---|---|
|
|
|
|
Sum of Lifetime Value (USD) | Column Labels |
|
|
Row Labels | 2024 Q1 | 2024 Q2 | Grand Total |
Stage 1 | 200 |
| 200 |
Stage 2 | 300 |
| 300 |
Stage 3 | 400 | 400 | 800 |
Grand Total | 900 | 400 | 1300 |
Opportunity number | 456 |
|
|
|---|---|---|---|
|
|
|
|
Sum of Lifetime Value (USD) | Column Labels |
|
|
Row Labels | 2024 Q1 | 2024 Q2 | Grand Total |
Stage 1 | 200 |
| 200 |
Stage 2 | 300 | 300 | 600 |
Stage 3 |
| 400 | 400 |
Grand Total | 500 | 700 | 1200 |
2 important notes:
- Only Stage Entry Lifetime Value per Opportunity and per Sales Stage.
- The Earliest Stage Entry Date per Opportunity and per Sales Stage is considered.
2 issues was encountered:
- Duplicated Lifetime Values
- For the Stage Enter Quarter, only the earliest Stage enter quarter should be considered:
- For the case of Opportunity number 123, only the $400 in 2024Q1 should be considered. But since Opportunity number entered Stage 3 twice (2x), Lifetime Value for 2024 Q2 was added also, making the total to $800 instead of $400 only.
- For the case of Opportunity number 456, only the $300 in 2024Q1 should be considered. But since Opportunity number entered Stage 3 twice (2x), Lifetime Value for 2024 Q2 was added also, making the total to $600 instead of $300 only.
Resolving the Issue#1: Duplicate Lifetime Values:
Using the "Stage Progression Active Flag" duplicate value is resolved by using this field in a calculation, using the following scenario using "CASE WHEN" sql statements:
- If the Stage Enter date is latest date(has Y value) , Lifetime Value is added to the pivot table
- If the Stage Enter date is not the latest date (has N value), Lifetime Value is 0.
Note: Lifetime value is also Y if the "Opportunity Number || Sales Stage name" line item is unique
Remaining issue:
Using the data in the first table, how to get only the line item with "earliest/first" stage enter date into the pivot table without having duplicate lifetime values?
====
Stage Entry Lifetime Value Custom calculation:
sum( CASE
WHEN "Sales Stage Name" = 'Stage 1'
and "Stage Progression Active Flag" = 'Y'
THEN "Table for Lifetime Value Stage 1"
WHEN "Sales Stage Name" = 'Stage 2'
and "Stage Progression Active Flag" = 'Y'
THEN "Table for Lifetime Value Stage 2"
WHEN "Sales Stage Name" = 'Stage 3'
and "Stage Progression Active Flag" = 'Y'
THEN "Table for Lifetime Value Stage 3"
ELSE 0 END)
==
Also added this filter to include only line item with minimum stage enter date:
"Stage Enter Date" = (min("Stage Enter Date" by ."Opportunity Number", ""Sales Stage Name" ) )
As a result, the filter has no effect on the results.
Please help provide suggestion on how we can go about this. Thanks!
Answers
-
Please do not double (triple) post :
If your post doesn't get any reply, maybe try to explain your case differently replying to your original post instead of asking again the same exact thing hoping for a different outcome…
0
