Dynamic calc to sum months across years
I have an Essbase 6.5.5 cube with a periods dimension containing months and weeks as stored members, tagged as time. I also have a year dimension that contains fiscal years and these members are also stored. I need to add together the first month of this year and the last month of last year.
I can do this:
M12->LY + M01->TY
This gives me the right answer and I could setup IF statements to cross dim to the correct LY value, but I would like the formula to dynamically select the correct LY based on the TY year the user sets up in their query. I tried a few combos using @prior and @shift and it is not working correctly.
Here's what I thought would work:
M01 + (@SHIFT(Year,-1));
This formula results in summing just the M01 and nothing from LY. Any thoughts on how to set this formula up?
Edited by: user11908498 on Sep 16, 2009 5:55 AM
Edited by: user11908498 on Sep 16, 2009 11:42 AM
My mistake Gary, the periods dimension is tagged as time and contains months and weeks as stored members. The year dimension contains fiscal years as stored members. I have updated my OP to state that correctly.
Using your formula:
"M01" + @SHIFT("M12", -1, @CHILDREN("Year"));
I'm still just getting the answer of the data contained in M01.
M12 is in the period dimension tagged as time.
Year is the fiscal year dimension as a stored member.
What I want to get is the sum of M01->TY + M12->LY without hard coding the year in a cross dim statement. It seems like this should be a simple formula, but its not working for me.
Similar Messages
-
Dynamic filter by Country, month and year
Hi,
I have a file extracted from SAP BI and incrusted in xls format in Xcelsius.
I have to filter data by Country, year, and month. I´ve seen the blog of Ingo Hilgefort 'Creating an Xcelsius dashboard on top of SAP BI that has a similar expanation of what I need to do.
Unfortunatelly, the problem I ´m facing is how to organize the data including the months in the spreadsheet incrusted in the Xcelsius.
What I have at the moment in the spreadsheet is a column with countries (9), an one column by KPI (10). Beside the last column I have the inserted data column for the countries so in the dashboard I can pick a country and shows me the KPI´s by country. What I still don´t found is how to make the selection also by month and year.
If anyone could help, I would be grateful.
Thanks in advance,
DiegoCharles,
It seems to be what i´m looking for. It is perfect to see the KPI´s by country and month in a year.
But with that spreadcheet i still cannot choose only the KPI´S year values by countries (independently of the month).
Another question I would like to make to you (as i told you i´m making my first steps in Xcelsius) is if you write the formula =BUSCARV($C$7;$C$17:$G$23;5;FALSO) manually into the excel.
Thanks in advance,
Diego -
Problem with a calc involving @MDSHIFT and Dynamic Calc
Hi all,
I have a problem with the calculation of a member in a calc script. The formula of this member is :
"R70100"
IF(@ISMBR("M01"))
("T_008"->"Cumul"->"HT"+"T_003"->"Cumul"->"HT")*"AVCT_PR" - @MDSHIFT("R70100" -> "Cumul" -> "HT" -> "M12", -1, "Year", );
ELSE
("T_008"->"Cumul"->"HT"+"T_003"->"Cumul"->"HT")*"AVCT_PR" - @MDSHIFT("R70100" -> "Cumul" -> "HT", -1, "Period", );
ENDIF
- R70100 is a member of a dense dimension.
- T_008, T_003 and AVCT_PR are spare and stored.
- "Cumul" is a dynamic member which allow us to calculate cumulative from monthly.
- Time is split into two dimensions, Period and Year.
The problem is that the @MDSHIFT doesn't seems to work with the dynamic calc as the monthly result is the cumulative correct value. I didn't know what is wrong BUT each time I launch the script, values are good for one more month.
After one run, for example, I obtained this result :
!http://zenon.apartia.fr/stuff/200910070001.GIF!
Two run later, here are the news values :
!http://zenon.apartia.fr/stuff/200910070002.GIF!
Any idea on what going on and how to correct it ? Thanks !
FrédéricA couple of questions for you:
1) Do you need the overhead of @MDSHIFT when you are only moving in one dimension? Wouldn't @PRIOR have been a lot easier? At least this is true for the ELSE condition.
2) Could you post just the results of the @MDSHIFT calculation so we (okay, this may be just for me, it's still breakfast time here and not enough coffee has been ingested yet to read a spreadsheet without recourse to the formulas) can better see the impact?
3) Have you tried using your code against a non-dynamic member? Does it make a difference?
Regards,
Cameron Lackpour -
Dynamic Calc Member with Formula to Calculate a Rolling 13 Year
I have to create a rollup in my time dimension that will have 13 members representing each month of a 13 rolling forecast. I am having trouble setting this up as dynamic calc members with a formula assigned to it. For example, on of the members has the following formula.
As you can see, I am referencing several substitution variables since I want to make this as most dynamic as possible without having to make any changes to the formula member. Only making changes to the substitution variable. Any help would be much appreciated.
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Jan"));
"RTM 6" = @MDSHIFT(&Act_RF_Last_Month, -1, "Years", , 5, "Period",);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Feb"));
"RTM 6" = @MDSHIFT(&Act_RF_Last_Month, -1, "Years", , 5, "Period",);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Mar"));
"RTM 6" = @MDSHIFT(&Act_RF_Last_Month, -1, "Years", , 5, "Period",);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Apr"));
"RTM 6" = @MDSHIFT(&Act_RF_Last_Month, -1, "Years", , 5, "Period",);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "May"));
"RTM 6" = @MDSHIFT(&Act_RF_Last_Month, -1, "Years", , 5, "Period",);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Jun"));
"RTM 6" = @MDSHIFT(&Act_RF_Last_Month, -1, "Years", , 5, "Period",);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Jul"));
"RTM 6" = @MDSHIFT(&Act_RF_Last_Month, -1, "Years", , 5, "Period",);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Aug"));
"RTM 6" = @SHIFT(&Act_RF_Last_Month,-7);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Sep"));
"RTM 6" = @SHIFT(&Act_RF_Last_Month,-7);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Oct"));
"RTM 6" = @SHIFT(&Act_RF_Last_Month,-7);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Nov"));
"RTM 6" = @SHIFT(&Act_RF_Last_Month,-7);
ELSE #Missing;
ENDIF
IF((@ISMBR(&Current_Year)) AND (&Act_RF_Last_Month == "Dec"));
"RTM 6" = @SHIFT(&Act_RF_Last_Month,-7);
ELSE #Missing;
ENDIFWe use similar logic but its in a calc script, not a dynamic formula.
Here's an example of what we do:
FIX (&Year, &Scenario)
IF (@ISMBR("JAN"))
"Average Usage%" = @AVG(SKIPBOTH, @MDSHIFT("Usage %"->"DEC"->&actYear, -1, "Year",), "Util %"->"JAN"->&actYear);
ELSEIF
ENDFIX
Another example in a different database:
IF (@ISMBR("JAN")) ((@MDSHIFT("Fees"->APR,-1,YEARS,)+@MDSHIFT("Fees"->MAY,-1,YEARS,)+@MDSHIFT("Fees"->JUN,-1,YEARS,)+@MDSHIFT("Fees"->JUL,-1,YEARS,)+@MDSHIFT("Fees"->AUG,-1,YEARS,)+@MDSHIFT("Fees"->SEP,-1,YEARS,)+@MDSHIFT("Fees"->OCT,-1,YEARS,)+@MDSHIFT("Fees"->NOV,-1,YEARS,)+@MDSHIFT("Fees"->DEC,-1,YEARS,)+"Fees"->JAN)/10)*12; -
Hyperion Planning dynamic forms based on start and end date across years
Hi All,
I have a requirement where i need to be able to view a form showing periods across years that are dynamically built depending on the start and end dates. If i have a start date of 01/11/2009 and an end date of 31/7/2013 i want to be able to view a form that shows all of the periods (Jan,Feb etc) in a form that is driven by these dates, in addition it will need to show the actual scenario up to the current month and the forecast from the current month to the end date. So basically if a user inputs the start and end dates the form will display the relevant periods driven by these dates.
Any tips very much appreciated!Hello,
This is difficult to realize, but you can get quite far with a workaround. The first question is, where do you want to input your selection of time periods? Assuming you have a webform with the complete timeline in months and years and you type in the start period and end period.
Webforms have the option to suppress rows and columns.
This can be extended with option of empty cells or not empty cells.
You will need to apply your creativity on this.
Put every month-year combination in a column and add the suppression.
Calculate the timeline between start period and end period with a dummy member, so data exists for these and columns will show.
Maybe you will need to copy the required timeline into a separate version for this, to avoid having periods which were outside the selection and still have data.
I hope these hints help a bit in this challenge.
Regards,
Philip Hulsebosch
www.trexco.nl -
The image above is an example of a dataset I have in SSRS. Unique items in the table is over 60. Currently it is aggregated by month and by year (total for all items). A user has to manually add up an item's total for the month or even for the year.
Now, they want to be able to see the sum as well as the average of an item by month, by year. For example, from the chart, to get the total value of item D, we will have to manually add up across the year. How do I meet this requirement
using SSRS?
Thank you.
ZionliteHi ,
You can do simply this in SSRS using tablix
1. by grouping on year and month and product.
2. then do summation/Avg for year and month and product that you require.
https://msdn.microsoft.com/en-us/library/dd220511.aspx?f=255&MSPPError=-2147217396
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com -
Formula to go across years and months to find the value
Hello,
I am having difficulty writing a member formula where the rate is supposed to come from anyplace that's available prior to that month and year. This is for Re-forecasting purposes.
The example of how the concept should work is shown below. I have tried @priors, @shift, and @rangelastval. None of these calculations have been able to go through multiple years at the same time to get the rate from previous years and month. It works in the same year across the periods but not both periods and years.
Any idea what calculation function or a combination of calculation functions I can use so the calculated amount goes back as many years and months possible until it finds the rate.
Year
Periods
Rate
Amount
Calculated amount
FY15
Jan
0
100
0
FY15
Feb
0
100
0
FY15
Mar
0.4
100
40
FY15
Apr
0
100
40
FY15
May
0
100
40
FY15
Jun
0
100
40
FY15
Jul
0
100
40
FY15
Aug
0
100
40
FY15
Sep
0
100
40
FY15
Oct
0
100
40
FY15
Nov
0
100
40
FY15
Dec
0.3
100
30
FY16
Jan
0
100
30
FY16
Feb
0
100
30
FY16
Mar
0
100
30
FY16
Apr
0
100
30
FY16
May
0
100
30
FY16
Jun
0
100
30
FY16
Jul
0
100
30
FY16
Aug
0
100
30
FY16
Sep
0
100
30
FY16
Oct
0
100
30
FY16
Nov
0
100
30
FY16
Dec
0
100
30
FY17
Jan
0
100
30
FY17
Feb
0.5
100
50
FY17
Mar
0
100
50
FY17
Apr
0
100
50
FY17
May
0
100
50
FY17
Jun
0
100
50
FY17
Jul
0
100
50
FY17
Aug
0
100
50
FY17
Sep
0
100
50
FY17
Oct
0
100
50
FY17
Nov
0
100
50
FY17
Dec
0
100
50
FY18
Jan
0
100
50
FY18
Feb
0
100
50
FY18
Mar
0
100
50
FY18
Apr
0
100
50
FY18
May
0
100
50
FY18
Jun
0
100
50
FY18
Jul
0
100
50
FY18
Aug
0
100
50
FY18
Sep
0
100
50
FY18
Oct
0
100
50
FY18
Nov
0
100
50
FY18
Dec
0
100
50
FY19
Jan
0
100
50
FY19
Feb
0
100
50
FY19
Mar
0
100
50
FY19
Apr
0
100
50
FY19
May
0
100
50
FY19
Jun
0
100
50
FY19
Jul
0
100
50
FY19
Aug
0
100
50
FY19
Sep
0
100
50
FY19
Oct
0
100
50
FY19
Nov
0
100
50
FY19
Dec
0
100
50
FY20
Jan
0
100
50
FY20
Feb
0
100
50
FY20
Mar
0
100
50
FY20
Apr
0
100
50
FY20
May
0
100
50
FY20
Jun
0
100
50
FY20
Jul
0
100
50
FY20
Aug
0
100
50
FY20
Sep
0
100
50
FY20
Oct
0
100
50
FY20
Nov
0
100
50
FY20
Dec
0
100
50
FY21
Jan
0
100
50
FY21
Feb
0
100
50
FY21
Mar
0
100
50
FY21
Apr
0
100
50
FY21
May
0
100
50
FY21
Jun
0
100
50
FY21
Jul
0
100
50
FY21
Aug
0
100
50
FY21
Sep
0
100
50
FY21
Oct
0
100
50
FY21
Nov
0
100
50
FY21
Dec
0
100
50
Thanks in advance!ELSE
IF (@PRIORS(SKIPMISSING, RATE) == #Missing)
IF (@ISMBR(&FcstYear7))
"Amount"=Amount*@PRIORS(SKIPMISSING,"Rate",(&FcstStartMo:"Dec"->&FcstYear1, "Jan":"Dec"->&FcstYear2,"Jan":"Dec"->&FcstYear3,"Jan":"Dec"->&FcstYear4,"Jan":"Dec"->&FcstYear5,"Jan":"Dec"->&FcstYear6)));
similarly repeated for the years 6,5,4,3,2 but it gave the following error "Error: 1200400 Error executing formula for [Check_1] (line 9): scalar double argument expected in function [@_UMINUS]"
How can I use XRANGE in this because the function has the following limitation?
@XRANGE can be used only in these functions: @AVGRANGE, @SUMRANGE, @MINRANGE, @MINSRANGE, @MAXRANGE, @MAXSRANGE, @STDDEVRANGE, @MOVSUM, @MOVAVG, @MOVMIN, @MOVMAX, @MOVMED, @SPLINE. -
Dynamic selection of Calendar month/year
I need to create a dynamic combo for calendar month/year, which will display the last 3 months.
I have a query that displays the cumulated amounts for the last three months and I need to have a combo with the option to filter the query for only one of these months...
How can I do that in Visual Composer?
Thanks in advance,
CrisHi Cris,
The simplest way is to create a service that's returns the correct month and use it as dynamic list for the drop-down.
Hope it helps,
Shay -
How to calc the begining and end of every month (leap year)
Hi all,
I'm looking for a method that returns the begining and end of next month.
example:
today is 2005-10-04
so the method suppose to return:
2005-11-01
2005-11-31 //as it ends on the 31
I came up with the code below - but I don't like it as I can't get the end of month + it's not safe.
any suggestions.
Thanks
Peter
Calendar gcToday = Calendar.getInstance();
int month = gcToday.get(Calendar.MONTH);
int year = gcToday.get(Calendar.YEAR);
month+=2;
if(month>12) //beacuase of month+=2;
year++;
month=1;
String nextMonth;
if (month<10)
nextMonth=year+"-0"+month+"-01";
else
nextMonth=year+"-"+month+"-01";Look at using the methods getActualMaximum() and getActualMinimum() in the Calendar class. Basically what I would do is set the calendar to the 15th of the month (well, really anything between 1 and 28) and then add() one to the current month. The Calendar will roll over the dates as needed.
-
Essbase : Order evalution with dynamic Calc : Account x Scenario
Hi everybody,
I'm trying to calculate a variation N / N-1 in % for All Accounts.
basically : %/ N-1 = (Actual- Actual N-1) / Actual N-1 - I create a scenario.
I create a scenario %_N_1 which is Dynamic Calc.
"%_N_1" = ("ACTUAL" - @MDSHIFT( "ACTUAL" , -1 , "Year" , ))/@MDSHIFT( "ACTUAL" , -1 , "Year" , )*100;
But with agregated Accounts (which are dynamic calc also), Essbase sums the % ... which is wrong !!!
Question : How could we set the priority between Scenario and Account for Dynamic Calculation.
regards,
ps : I want not to put this calculation in Financial Reporting, because there are a lot of reports that use this measure : %_N_1 !Two-pass Calc
You should basically put this on every formula that is a % to make sure it happens after the aggregation stuff.
It get's tricky if you did two-pass on two pass but I believe you aren't using two-pass so you should be good to go -
Have a Dyname Calc member using this 1. formula and IT IS working fine. I want to add another piece to it so that my monthly members act the same way 2.
So far the 2. part does nothing. Can anyone provide me some hints or tips on why this has no affect on my monthly members?
1.
IF (@ISLEV (\"Time\", 0)) \"27102\" * -1;
ELSEIF (@ISMBR (\"Q1\")) \"27102\"->\"Q1\" * -1;
ELSEIF (@ISMBR (\"Q2\")) (\"27102\"->\"Q2\" - \"27102\"->\"Q1\") * -1;
ELSEIF (@ISMBR (\"Q3\")) (\"27102\"->\"Q3\" - \"27102\"->\"Q2\") * -1;
ELSEIF (@ISMBR (\"Q4\")) (\"27102\"->\"Q4\" - \"27102\"->\"Q3\") * -1;
ELSEIF (@ISMBR (\"Total Year\")) \"27102\"->\"P12\" * -1;
ELSEIF (@ISMBR (\"P1YTD\")) \"27102\"->\"P1YTD\" * -1;
ELSEIF (@ISMBR (\"P2YTD\")) \"27102\"->\"P2YTD\" * -1;
ELSEIF (@ISMBR (\"P3YTD\")) \"27102\"->\"P3YTD\" * -1;
ELSEIF (@ISMBR (\"P4YTD\")) \"27102\"->\"P4YTD\" * -1;
ELSEIF (@ISMBR (\"P5YTD\")) \"27102\"->\"P5YTD\" * -1; .
ELSEIF (@ISMBR (\"P6YTD\")) \"27102\"->\"P6YTD\" * -1;
ELSEIF (@ISMBR (\"P7YTD\")) \"27102\"->\"P7YTD\" * -1;
ELSEIF (@ISMBR (\"P8YTD\")) \"27102\"->\"P8YTD\" * -1;
ELSEIF (@ISMBR (\"P9YTD\")) \"27102\"->\"P9YTD\" * -1;
ELSEIF (@ISMBR (\"P10YTD\")) \"27102\"->\"P10YTD\" * -1;
ELSEIF (@ISMBR (\"P11YTD\")) \"27102\"->\"P11YTD\" * -1;
ELSEIF (@ISMBR (\"P12YTD\")) \"27102\"->\"P12YTD\" * -1;
ENDIF;
2.
ELSEIF (@ISMBR (\"P1\")) \"27102\"->\"P1\" * -1;
ELSEIF (@ISMBR (\"P2\")) \"27102\"->\"P2\" * -1;
ELSEIF (@ISMBR (\"P3\")) \"27102\"->\"P3\" * -1;
ELSEIF (@ISMBR (\"P4\")) \"27102\"->\"P4\" * -1;
ELSEIF (@ISMBR (\"P5\")) \"27102\"->\"P5\" * -1;
ELSEIF (@ISMBR (\"P6\")) \"27102\"->\"P6\" * -1;
ELSEIF (@ISMBR (\"P7\")) \"27102\"->\"P7\" * -1;
ELSEIF (@ISMBR (\"P8\")) \"27102\"->\"P8\" * -1;
ELSEIF (@ISMBR (\"P9\")) \"27102\"->\"P9\" * -1;
ELSEIF (@ISMBR (\"P10\")) \"27102\"->\"P10\" * -1;
ELSEIF (@ISMBR (\"P11\")) \"27102\"->\"P11\" * -1;
ELSEIF (@ISMBR (\"P12\")) \"27102\"->\"P12\" * -1;
ENDIF;If P1 thru P12 are level 0, maybe your first statement @ISLEV("Time",0) AND your @ISMBR("P1") are BOTH getting executed, thus *-1 applied twice = no change. Although you would expect that subsequent ELSEIF would not be executed if the first IF were satisfied.
-
6.5 vs 6.2 Dynamic calc member in basis of @allocate function
I just converted from 6.2 to 6.5 and have run across a problem in the @allocate function. It appears that it does not resolve the dynamic calc member. Formula is:"Curr Fcst"=@ALLOCATE("SumInput"->"Curr Fcst", @remove(@descendants(@currmbr(Accounts)),@Descendants(@CURRMBR(Accounts),-1)), "Consolidated"->"Curr Fcst"->&LactlmonTD, ,share); The problem is that &LactlmonTD - a substitution variable is "MAY YTD", which is a dynamic calc member. The formula works fine for a stored member "May" if you want to allocate based on last month only. This formula worked in 6.2, but does not work in 6.5 that I can see. Any ideas short of storing the data for YTD? I am logging it as a bug with hyperion.
OK - Hyperion technical support has solved the issue with an "Undocumented feature". I needed to add the following statement to my Essbase.cfg file:CALCFGDEPOPT FALSEThe explaination was as follows:"This is basically to turn off EVENT 28 in Essbae 6.5. In Essbase 6.2 EVENT28 needs to be turned on manually in the config file, while in Essbase 6.5it is automatically turned on."
-
DATACOPY from Dynamic Calc Member not working
Hello,
I have a BR to Copy from one Scenario to another. I let the user chose the Scenario via RTP. When they chose a dynamic calc scenario no data is copied.
Here is the Rule
SET CREATENONMISSINGBLK ON;
SET COPYMISSINGBLOCK ON;
FIX(Dec, "Daten brutto", "Daten_brutto_P_M")
DATACOPY [TEBIT_COPY_Year_Source]->[TEBIT_COPY_Scenario_Source]->Final TO [TEBIT_COPY_Year_Target]->[TEBIT_COPY_Scenario_Target]->Version_1;
ENDFIX
I fix on some specific Members an then copy from a specific Year->Scenario combination the Final Version to another Year->Scenario combination Version_1. Doing this with a store Scenario works, with a dynamic calc Scenario it doesnt.
Thx for your Help.Kevin,
Unfortunately, I think this is the way it works. DATACOPY will not copy dynamically calculated members to stored members.
Although it is not in the DATACOPY Tech Ref documentation, that's the way it works.
Here are some older threads on the "other" board:
http://www.network54.com/Forum/58296/thread/1184768427/DATACOPY+Help
http://www.network54.com/Forum/58296/thread/1054220911/Datacopy+Problem
You are going to have to come up with another way of copying the Scenario by summing the members into the target Scenario. It can be a pain because you're going to have to mind the creation of the blocks. SET CREATEBLOCKONEQ will be your friend on this one.
Regards,
Cameron Lackpour -
Hi all Thanks in Advance
I need help in Pivoting Data
SELECT ID,MONTH,COUNT FROM TABLE_PIVOT ORDER BY ID,MONTH
ID MONTH COUNT
10 10/01/2009 60
10 11/01/2009 80
10 12/01/2009 78
10 01/01/2010 81
10 02/01/2010 73
10 03/01/2010 84
10 04/01/2010 100
10 05/01/2010 107
10 06/01/2010 90
10 07/01/2010 0
10 08/01/2010 0
10 09/01/2010 73
20 10/01/2010 71
20 11/01/2010 76
20 12/01/2010 79
20 01/01/2011 79
20 02/01/2011 81
20 03/01/2011 88
20 04/01/2011 97
20 05/01/2011 87
20 06/01/2011 97I tried to pivot with below query
SELECT ID,
SUM(DECODE(to_char(month,'MM'),'01',count,0)) " Jan",
SUM(DECODE(to_char(month,'MMYY'),'02',count,0)) Feb,
SUM(DECODE(to_char(month,'MM'),'03',count,0)) Mar,
SUM(DECODE(to_char(month,'MM'),'04',count,0)) Apr,
SUM(DECODE(to_char(month,'MM'),'05',count,0)) May,
SUM(DECODE(to_char(month,'MM'),'06',count,0)) June,
SUM(DECODE(to_char(month,'MM'),'07',count,0)) July,
SUM(DECODE(to_char(month,'MM'),'08',count,0)) August,
SUM(DECODE(to_char(month,'MM'),'09',count,0)) September,
SUM(DECODE(to_char(month,'MM'),'10',count,0)) October,
SUM(DECODE(to_char(month,'MM'),'11',count,0)) November,
SUM(DECODE(to_char(MONTH,'MM'),'12',count,0)) December
FROM Table_PIVOT
GROUP BY ID
ORDER BY ID
ID Jan FEB MAR APR MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER
10 81 0 84 100 107 90 0 0 73 60 80 78
20 79 0 88 97 87 97 0 0 0 71 76 79I want output to display the column names with Month and Year like below
ID Oct-2009 Nov-2009 Dec-2009 Jan-2010 Feb-2010 ................... OCT-2010 NOV-2010 DEC-2010 JAN-2011 FEB-2011 ......
10 60 80 78 81 73 ...................
20 71 76 79 79 81
CREATE TABLE "TABLE_PIVOT"
( "ID" NUMBER,
"MONTH" DATE,
"COUNT" NUMBER
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('10/01/2009','MM/DD/YYYY'),60);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('11/01/2009','MM/DD/YYYY'),80);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('12/01/2009','MM/DD/YYYY'),78);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('01/01/2010','MM/DD/YYYY'),81);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('02/01/2010','MM/DD/YYYY'),73);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('03/01/2010','MM/DD/YYYY'),84);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('04/01/2010','MM/DD/YYYY'),100);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('05/01/2010','MM/DD/YYYY'),107);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('06/01/2010','MM/DD/YYYY'),90);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('07/01/2010','MM/DD/YYYY'),0);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('08/01/2010','MM/DD/YYYY'),0);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('09/01/2010','MM/DD/YYYY'),73);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('10/01/2010','MM/DD/YYYY'),71);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('11/01/2010','MM/DD/YYYY'),76);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('12/01/2010','MM/DD/YYYY'),79);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('01/01/2011','MM/DD/YYYY'),79);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('02/01/2011','MM/DD/YYYY'),81);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('03/01/2011','MM/DD/YYYY'),88);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('04/01/2011','MM/DD/YYYY'),97);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('05/01/2011','MM/DD/YYYY'),87);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('06/01/2011','MM/DD/YYYY'),97);
COMMIT;Hi,
user1849 wrote:
Any Sample code is appreciated
I didn't see any solution for following one in your linklI think Centinul was specifically referring to:
Help for a query to add columns
but other links from
SQL and PL/SQL FAQ
may help you more.
>
Re: How to pipeline a function with a dynamic number of columns?
Posted: May 9, 2006 2:58 PM in response to: Billy Verreynne Reply
Interesting stuff! It's going to take me awhile to digest it.
For what it's worth, I was trying to build a pivoting function that would take a MYTABLE table like this:
YEAR CITY X Y
2000 BAL 95 96
2000 BOS 101 101
2001 BAL 92 94
2001 BOS 101 101
2002 BAL 98 98
2002 BOS 98 99
2003 BAL 95 96
2003 BOS 105 104
and allow me to do something like:
CREATE VIEW MYPIVOT
AS
SELECT *
FROM TABLE (PIVOT(MYTABLE, [with other params]))
and get the following view MYPIVOT on the table:
YEAR BOS_X BOS_Y BAL_X BAL_Y
2000 101 101 95 96
2001 101 101 92 94
2002 98 99 98 98
2003 105 104 95 96
Where the number of distinct CITY values will vary over time. I am able to build the query I need dynamically, but since the CITY data values in the original table change, the columns are not necessarily static from invocation to invocation. Therefore I didn't want to just create a view using the dynamic SQL once, because it may need to be created next time I need to access the view. I wanted to be able to access the pivoted data on demand.A pipelined function is your best bet for that.
I couldn't do was be able to execute the query and treat it as a pipelined function, hence my original question.Sorry, I don't understand.
I'll dig into the code above to see if it does what I wanted, but if someone has a better suggestion on how to approach this, I'd be interested in hearing it.A completely different approach is String Aggregation , where you would get output like this:
YEAR TXT
BOS_X BOS_Y BAL_X BAL_Y
2000 101 101 95 96
2001 101 101 92 94
2002 98 99 98 98
2003 105 104 95 96Note that this output contains 6 rows and 2 columns. On the first row, year is NULL and txt=' BOS_X BOS_Y BAL_X BAL_Y'. You can do this is pure, static SQL, without knowing the number of cities in advance. -
I'm working with a dynamic calc cube - version 7.X - with the following dimensions: Accounts, Period, Fiscal Year, Scenario, Version, Organization
In the scenario dimension we have the following members: Budget, Actual, Forecast.
I want to create a Scenario member that displays the variance between current year Forecast and prior year Actual.
I've used @VAR("Forecast","Budget") to create a variance Scenario member within the same year, but can't figure out how to do it across years.
Any ideas? Thanks.@VAR doesn't support cross dimensional members.
However, you could do this (this approach requires an "Expense" UDA to match Expense Reporting members and is assuming you are comparing FY10 Budget to FY09 Actual):
Dynamically calculated formula in member "Bud FY10 vs. Act FY09"
IF(@ISUDA("Account", "Expense") AND @ISMBR("FY10"))
"Actual"->"FY09" - "Budget"->"FY10" ;
ELSEIF(NOT(@ISUDA("Account", "Expense")) AND @ISMBR("FY10"))
"Budget"->"FY10" - "Actual"->"FY09" ;
ENDIF
You could get fancier with @PRIOR and @CURRMBR if you wanted to make it more flexible.
The important thing is to be able to identify the Expense accounts from the non-Expense because it flips the subtraction direction.
Regards,
Cameron Lackpour
Maybe you are looking for
-
Will 4.0.2 upgrade delete all my iPhone applications?
Hi there, I'm a iPhone 3GS user and I've been wondering if upgrading the software to 4.0.2 will delete all my applications/pictures/music. Also, if you tried 4.0.2 already, do you recommend it or not? I love the fact that you can now create folders f
-
Mac Pro 1,1 hangs indefinately at startup: Help Me Diagnose?
Hello all, trying to determine what could possibly be causing this issue with my Mac Pro Quad 2.66 xeon machine running Snow Leopard. It will turn on but does not boot up, instead hanging indefinately at the white screen with apple logo, displaying a
-
Unable to read payload from the message object in XI
Hello Guys, Please help me about my problem in XI version 7.0.im quite new here. im trying to test my config but error message occured. "Unable to read payload from the message object" when i checked the comm channel this is the error message : Error
-
Hi, I have shipping data in 4.6c and they migrated to ECC6.0 . In that my requirement is i have to cofigure logical systems using we20 T.code and By using Inbound Parameter i am providing Message type and Process Code. Regarding this my question is i
-
How to delete a sales order which has already approved
Hi, Could anyone please tell me how can we delete an already approved Sales order if no delivery doc is created and billing document has already been cancelled. When i try to delete the order it is not allowing to delete the sales order. It allows to