Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Revenue Expressions

I have a question regarding writing an expression that sums revenue for the quarter.  I need to sum the total revenue for all the sales of the day in a quarter, and then add them to the total sales for all the previous days of the quarter.  The load statement takes the scripts from an excel file, and so there could be 30 sales on day 11 of Q2 FY12, and they are scattered throughout the excel file with no clear organization.

T=Total Sales for the Day;               TRTD= Total Revenue to Date (based on day # in quarter).

Example; Day 1 sales( 1A+1B+1C=1T), Day 2 sales( 2A+2B=2T) Day 2 total revenue = 1T+2T=Total Revenue to Date; Day 3 Sales =(3A+3B+3C+3D=3T); Total Revenue = 1T+2T+3T=TRTD….Once I have that expression written, I need to be able to compare the total revenue on say day 45 of this quarter over day 45 of the previous quarter (total revenue for the entire quarter summed for each one), and the total revenue for the current quarter over the same quarter in the previous fiscal year.

Thanks for your help and hope I was clear, and please let me know any further questions you have.  Unfortunetly I cannot upload any of the files themselves because they contain confidential data for a publicly traded company.

Alex

1 Solution

Accepted Solutions
IAMDV
Luminary Alumni

Hi Alex,

Here is my approach.

Most important thing to understand is how do you want your end users to access the report. There are two ways...

You can calculate Max Year, Max Quarter and Max Month for the whole document. This way users will always view the latest data. I mean I would use {1} instead {$} where {1} represents full dataset and {$} for current selection.

Now, I am using the first approach to always show current period and previous period.

Step 1: Declaring Variables

I would declare my variable to calculate the CurrentYear, CurrentQTR, CurrentMonth & CurrentWeek. Something like this...

vCurrentQTR      = Max({1} QuarterID)

vPreviousQTR     = Max({1} QuarterID) -1

Same will be case for all the time dimensions.

*Please note that you can declare these variable in Load Script for better performance instead of declaring within QV document.

Step 2: Expression Building

Now, I would use these variable to create expressions. For example if I wanted to calculate Sales for CurrentQTR & PreviousQTR. I would use the below expressions...

Sales for Current   QTR : Sum({$<QuarterID={$(=($(vCurrentQTR)))}>}  Sales)

Sales for Previous QTR : Sum({$<QuarterID={$(=($(vPreviousQTR)))}>}  Sales)

Again, You can just replace your variable for other time dimensions with same expression.

Let's Assume If you wanted to QTR over QTR Sales then I would use...

Sum({$<QuarterID={$(=($(vCurrentQTR)))}>}  Sales) / Sum({$<QuarterID={$(=($(vPreviousQTR)))}>}  Sales)

_________________________________________________________________________________________________________________________________

Let's assume that you wanted to give the power to User to select Time Dimensions. I mean if you wanted to calculate the above expression for current selection then simply replace {1} with {$} in your variables.

I had used this approach for many projects. The main advantage is code re-usability and accuracy of expression. I mean my variables are actually underlying expressions and I can control them from one location and re-use them whenever required.

I hope this all makes sense. I understand that this might seem little complex at the beginning...but it will be very easy once you understand approach. Do let me know if you have more questions. I wish I could access some of your sample data to provide QV demonstration

I haven't answered your question to the 3rd point (regarding 46 day in current QTR). I will do that sometime this evening. Meanwhile you have something to work on

Good luck and sorry for the long past... you might need a break now!!!

Cheers - DV

View solution in original post

15 Replies
IAMDV
Luminary Alumni

Hi Alex,

This is definetly possible. Have you loaded the Master Calendar table from the Load Script which caluclates TRTD/ Till date? If not, then I would recommend loading them in load script and this helps while writing expressions. Also please use Set Analysis inside the variables and then you can re-use the variables for comparison. I hope this helps!

I am also attaching the Master Calendar example (I guess it is Rob's example).

Cheers - DV

Not applicable
Author

Thanks for the quick response DV,

I have a calendar loaded into the load script, its the calendar that our company uses so it includes the necessary fields.  It doesn't have the function necessary to calculate the total revenue for the quarter though.  I downloaded the master calendar you provided, and didn't see anything about revenue functions in it though.  Can I give you the fields I have and you can possible try and write up an example set analysis piece? 

I have the fields;

[Total Revenue ($)]

[Fiscal Quarter and Year]:  (format is 2011 Q2)

[Day # in FQ].

Any chance you can or anyone else can help me out and provide me with the basics for the set analysis for these fields?

IAMDV
Luminary Alumni

You are welcome

Sure, I will try to squeeze sometime to give you some idea on Set Analysis. I'll try to mock up some expressions... meanwhile if other users can help that will be brilliant. Regarding the previous document I had attached, please ignore that and have a look at the new attachment and look at the variable overiew window for Point in Time reporting. I hope this will give more ideas. Sorry, I had attached wrong document in previous post.

Cheers - DV

Not applicable
Author

Thanks so much DV,

This is great I can't thank you enough.  Now, how would i change the expressions to show the total revenue for the quarter only up to the current day in the quarter.  Right now I have, which currently shows through day 46 in the current quarter which is the day we are on, but for Q1 FY12, and Q2 FY11 it shows the total revenue through day 89, the end of the quarter...I only am using the one expression below and set the chart over the dimension [Fiscal QTR & Year].  Is this correct?

Sum($(vSetQTD)[TOTAL REVENUE ($)]

Thanks once again,

Alex

Not applicable
Author

Either that or create a button that sets the current date in qtr to 1-CD (ex: days 1-46), as [Day # in FQ] is a current field that I have.

Thanks,

Alex

IAMDV
Luminary Alumni

Hi Alex,

Good morning. I am not sure if you have got this working or if you need more support. I am little busy this morning but I can squeeze in sometime this evening. Do let me know your thoughts.

Cheers - DV

Not applicable
Author

Hey DV,

Still trying to work out this little problem, any support you can give me would be much appreciated!

thanks,

alex

IAMDV
Luminary Alumni

Hi Alex,

Let's work with my example (Demo PITR.QV). Let me understand your need with this document. So now you wanted to calculate Q1 Revenue in this example it will be Sales (Field). Please can you write down list of things you are trying to calculate.

I mean for example something like this...

1. Sales for Q1

2. MTD Sales

3. MTD Previous Month

If you can let me know what you wanted to calculate I can try to give you generic expression which you can use in your QV document. Or else if you are comfortable you can scramble the QV document and then send it to me.

Cheers - DV

Not applicable
Author

Ok I need to calculate

1. Quarter over Quarter Sales; which would be the (total sales for this quarter so far)/(total sales for last quarter)

2. Year over Year Sales; which would be (total sales for this quarter so far)/(total sales for the current quarter 1 year ago) ex:  2012 Q2/2011 Q2.

3.  An action or button or bookmark expression that would set the field [Day # in FQ] to 1-CurrentDate for all three quarters.      ex:  We are on day 46 in the current Fiscal Quarter, so I need all three quarters to only sum their revenues through day 46.  I'm assuming the easiest way to do this would be to create some sort of action.

Thanks greatly for all your help,

Alex