Sei sulla pagina 1di 2

12/24/2014

IN,ForEach&ForAllContextOperatorinBO|SAPBO,BI,Database&DatawarehouseFAQ

SAPBO,BI,Database&DatawarehouseFAQ| SubscribetoRSSFeed
WhyWeFollowtheWayifWecanLeadthe
SelectTopicsCategory
Way
SelectCategory

DearTechie!!
Welcometobobi.blog.comatechnoworldofBusinessIntelligence.
Throughthisblog,IhavetriedtoinitiateandsharemytechnialskillsinareaofSAPBusiness
Intelligence,SAPVisualIntelligence,BusinessAnalytics,Datawarehouse,Reportingand
databasesolutions.
Iwouldinviteandencourageyoutoreadthepostsandshareyourcommentandexpertiesonthe
topicsmentionedintheblogssothatthisblogcouldturnintotruehelpforthebeginnersandthe
advancelevelpractitionerofSAPBO/BI.
Thanksinadvanceforyourvaluablecontribution!!

IN,ForEach&ForAllContextOperatorinBO
FiledunderBO/BIAdministrationbyDeepakChaubeyon10032014
ForEachcontextoperator
TheForEachoperatoraddsdimensionstoacontext.i.e.ForEachisusedtoaddanextra
dimensionthatmightnotbeincludedintheblock(whichisvalidonlyforinputcontext).
Example:UsingForEachtoadddimensionstoacontext
ThefollowingtableshowsthemaximumrevenueforeachQuarterinareportwhichcontainsthe
Quarterdimensionbutdoesnotincludeitinthe
block:
ItispossibletocreateaformulafortheMaxQuarterlyRevenuecolumnthatdoesnotincludethe
ForEachoperator:
Max([SalesRevenue]In([Year][Quarter]))In([Year])

Authors
DeepakChaubey

AuthorIntroduction
Iamkeenenoughtolearntechnical
stuffasmuchpossible.Iusemy
leisuretimetosharemyknowledge
inareaofSAPbusinessobject,Business
Inteligence,DatawarehouseandDatabase
conceptswithcontexttodatabses(likeSql
server2005/2008/2012,Oracle
9i/10g/11i,SybaseASE,SybaseIQ,Mysql
5.5).Mypurposeistocreateasuper
BO/BI/Databaseblogwhichcontainsalmost
alltherespectivequestionsrelatedtoSAP
BOBI/BODS/HANAplatformInterviewsin
areaofadministration,developmentand
analysisfrombasictoadvancelevel.Idea
behindthisblogistosaveenoughtimefor
beginneraswellasexperiencedone.Ifyou
haveanyqueryregardinganyofthepostin
thisblog.youcanwritemeon:
sapbobiinfo@gmail.comIoffer&conducts
offline/OnlinetrainingcoursesforSAP
BO/BIandBODScourses.Checkbelowlink
toknowmoreaboutme:
http://about.me/deepakchaubey

Media

UsingtheForEachcontextoperator,youcanachievethesameresultwiththefollowingformula:
Max([SalesRevenue]ForEach([Quarter]))In([Year])
Why?BecausetheYeardimensionisthedefaultinputcontextintheblock.
ByusingtheForEachoperator,youaddtheQuarterdimensiontothecontext,
givinganinputcontextof([Year][Quarter]).
ForAllcontextoperator

Subscribe
Getthelatestpostsonyouremail!

Leaveyouremailaddress

OK

TheForAllcontextoperatorremovesdimensionsfromacontext.i.e.ForAllisusedtospecifically
excludeadimension,asallvaluesofthatdimensionareused.Example:UsingForAlltoremove
dimensionsfromacontext
YouhaveareportshowingYear,QuarterandSalesRevenueandyouwanttoaddacolumnthat
showsthetotalrevenueineachyear,asshowninthe
followingblock:
Tototalrevenuesbyyeartheinputcontextneedstobe(Year)bydefault
itis(YearQuarter).Therefore,youcanremoveQuarterfromtheinput
contextbyspecifyingForAll([Quarter])intheformula,whichlookslikethis:
http://bobi.blog.com/2014/03/10/inforeachforallcontextoperatorinbo/

1/6

12/24/2014

IN,ForEach&ForAllContextOperatorinBO|SAPBO,BI,Database&DatawarehouseFAQ

Sum([SalesRevenue]ForAll([Quarter]))
NotethatyoucanusetheInoperatortoachievethesamethinginthiscasetheformulais:
Sum([SalesRevenue]In([Year]))
ThisversionoftheformulaexplicitlyspecifiesYearasthecontext,ratherthanremovingQuarter
toleaveYear.
Simply,
InputContext:ForEach
OutputContext:ForAll

Meta
IN:INisusedtoprovidealistofdimensionstobeconsidered,andanyotherdimensionspresent
intheblockareignored.

Register
Login
EntriesRSS
CommentsRSS
PoweredbyBlog.com

Inotherword,
Inisusedtospecifyexactlywhichdimensionstoincludeinacontext.Otherdimensionsin
theblockareignored.Adding/removingelementsfromtheblockdoesnotimpactthis
calculationunlessaremoveddimensionwasspecifiedinthecontext.Inthatcasea
#MULTIVALUEerrorisdisplayed.
ForEachisusedtoincludeadimensioninacontext.Thecalculationcontextisstillaffected
byothervaluesintheblock.
ForAllisusedtoexcludeadimensionfromacontext.Otherdimensionsoftheblockwillstill
beconsidered.Addingorremovingvaluesfromablockmightchangethevalue,butitwill
alwaysignoretheForAllitems.

Mostvisited
SearchWithkeyword..LikeSQL
Search

MostRecentPost
10Keyfactsyouneedtoknowbefore
planningaMigrationprojecttoSAP
BOBI4.0project
MasterConceptofSAPBOBI
versions,SupportpacksandFixpacks
&Patchlevel
MasterConceptofAuditDBinBOBI4.0
StepbyStepforestablishingRFC
ConnectionbetweenSAPBW&Data
Service
StepstoUpgradefrom11.7/3.X/4.Xto
SAPDataServices4.2
HowtoVersioncontrolinBODS

Theoperatorslistedaboveallrequireoneormoredimensionsaspartoftheirsyntax.However,
calculationcontextcanbespecifiedbymorethanasetofdimensionvalues.Thereareaseriesof
reportstructurekeywordsthatcanbeusedaswell.
InReportsetsthecontextatthereportorgrandtotallevel.Anyformulawiththese
keywordsforthecontextwillreturnanoveralltotal.Notethatthetotalmaystillbeaffected
byreportfilters.
InBlocksetsthecontextforeachblocksection.ForyearsIhavebeenwaitingforthis
settingtoberenamedtoreflecthowitreallyworks,butithasnt.Isupposeitsfor
backwardscompatibility.IfthereisonlyoneblockonareportthenInBlockandIn
Reportaregoingtobethesame.Butwhenablockisbrokenupintosections,thenthis
contextwillgenerateatotalforeachsectionvalue.ForthatreasonIsubmitthatabetter
namemighthavebeenInSectioninstead,butaslongasIknowwhatitdoesthespecific
worddoesnotreallymatter.
InBodyisthestandarddefaultcontextforeachrowofdata.
WithDesktopIntelligencewehavetheoptionofInCurrentPagewhichcanbequiteusefuland
unfortunatelynotyetavailableinWebIntelligence.
Finally,thesekeywordscanappearinseveralplacesinaformula.Themostcommonarethe
inputandoutputcontextsettings,butcertainfunctions(likeRunningSum()forexample)also
havearesetcontext.
Inputcontextisusedtodeterminetheinputvaluesfortheformula.
Outputcontextisusedtodeterminetheoutputscopeoftheformula.
Resetcontextisusedtodeterminewhenarunningfunctionstartsoveratzero.
Dimensionsreferencedintheinputcontextdonothavetoappearintheblock.Outputandreset
dimensionsmustappearintheblockinordertofunctioncorrectly.Formanycalculationsthe
defaultinputcontextworksjustfine.

Like

Tweet

Share

(1)Comment
ReadMore

Comments:
OneResponse
http://bobi.blog.com/2014/03/10/inforeachforallcontextoperatorinbo/

MonthlyTopics
SelectMonth

Calendar
March2014
M T W T F S S

1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Feb

Apr

Pages
BetheMasterofinterview
70factsofUniverseDesigner!!
CreatingCascadingPromptsina
Universe
Dashboards
Dashboards
Datamodelling(DM)
Datawarehousesvsoperational
systems
DataWarehousingConcepts
SybaseASEVsSybaseIQ
SystemProcedures
Dr.Codd's12Rulesfora
2/6

Potrebbero piacerti anche