Multi-year Budgets vs. Allocations Power Pivot Table (from 2 different Excel tables)

%3CLINGO-SUB%20id%3D%22lingo-sub-2299580%22%20slang%3D%22en-US%22%3EMulti-year%20Budgets%20vs.%20Allocations%20Power%20Pivot%20Table%20(from%202%20different%20Excel%20tables)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2299580%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELong%20time%20excel%20user%2C%20first%20time%20poster.%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20attached%20example%20tables%20to%20facilitate%20an%20understanding%20of%20what%20I%20am%20trying%20to%20do.%20I%20am%20rather%20new%20to%20Power%20Pivot%2C%20Power%20Query%20(Get%26amp%3BTransform)%20and%20all%20of%20the%20wonderful%20features%2C%20but%20I%20am%20very%20familiar%20with%20Excel%20in%20general%2C%20and%20feel%20very%20comfortable%20learning%20new%20things.%20I%20have%20been%20successful%20in%20creating%20power%20pivot%20tables%20and%20using%20power%20query%20features%2C%20and%20have%20created%20bridging%20tables%20of%20unique%20entries%20in%20my%20own%20data%20models%20to%20help%20combine%20information%20to%20within%20single%20tables.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOn%20to%20the%20problem%3A%20I%20have%20two%20separate%20Excel%20tables%2C%20one%20tracking%20available%20Budgets%20year%20over%20year%2C%20and%20the%20other%20tracking%20allocations%20of%20funding%20to%20recipients%2C%20traceable%20back%20to%20the%20Budget%20reference%20titles%20(read%3A%20%22Budget%20source%22%20column%20in%20each%20table).%20The%20tables%20need%20to%20remain%20separate%2C%20and%20years%20need%20to%20remain%20as%20columns%2C%20not%20rows.%20However%2C%20there%20is%20a%20great%20deal%20of%20flexibility%20otherwise.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOverall%2C%20I%20am%20trying%20to%20create%20a%20Power%20Pivot%20table%20that%20will%20easily%20update%20itself%20and%20show%20year-over-year%20budget%20amounts%20per%20budget%2C%20total%20allocations%20from%20said%20budget%2C%20and%20the%20variance%20(surplus%2Funspent%20or%20deficit).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20added%20both%20tables%20to%20the%20data%20model%2C%20and%20a%20relationship%20can%20be%20drawn%20using%20%22Budget%20source%22%20column.%20However%2C%20I%20cannot%20seem%20to%20create%20a%20power%20pivot%20table%20that%20will%20show%20each%20budget's%20available%20amounts%20in%20one%20row%2C%20followed%20immediately%20by%20allocations%20from%20said%20budget%20in%20the%20second%20row%2C%20and%20then%20a%20variance%20equation%20automatically%20calculating%20whether%20there%20is%20any%20remaining%20money%20(surplus%2Funspent)%20or%20if%20it%20is%20oversubscribed%20(deficit).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20the%20attachment%20provides%20sufficient%20information.%20I%20have%20explained%20perhaps%20better%20in%20the%20notes%20boxes%20under%20each%20table%20what%20I%20am%20trying%20to%20do.%20I%20am%20sure%20this%20is%20doable%2C%20I%20am%20just%20not%20advanced%20enough%20in%20my%20understanding.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EOther%20info%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3EDevice%20and%20OS%20platform%3A%20PC%2C%20Windows%207%20Enterprise%3C%2FLI%3E%3CLI%3EExcel%20product%20name%20and%20version%20number%3A%20MS%20Excel%20Professional%20Plus%202016%20(16.0.5149.1000)%2C%2032bit.%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThank%20you%20ahead%20of%20time%20for%20your%20help%20and%20perspectives.%20Cheers!%3C%2FP%3E%3CP%3EAdam%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2299580%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2356686%22%20slang%3D%22en-US%22%3ERe%3A%20Multi-year%20Budgets%20vs.%20Allocations%20Power%20Pivot%20Table%20(from%202%20different%20Excel%20tables)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2356686%22%20slang%3D%22en-US%22%3EI%20think%20the%20only%20way%20to%20do%20that%20is%20not%20through%20power%20pivot%20because%20the%20power%20in%20the%20power%20pivot%20is%20in%20creating%20relationships%20(one%20to%20many).%20With%20many%20to%20many%20your%20only%20recourse%20is%20to%20unpivot%20both%20tables%20in%20power%20query%20then%20merge%20append%20both%20tables%20then%20add%20a%20designation%20column%20to%20id%20which%20data%20is%20a%20budget%20data%20and%20which%20data%20is%20the%20allocation%20data%20to%20differentiate%20them%2C%20then%20create%20a%20normal%20pivot%20table%20to%20summarize%20them.%20the%20budget%20id%20will%20go%20in%20column%20as%20well%20as%20the%20designation%20(i.e%20Budget%2C%20Allocation%2C%20and%20the%20total%20between%20the%20two%20will%20be%20the%20variance%20have%20to%20make%20the%20allocation%20a%20negative%20number%20though%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2356902%22%20slang%3D%22en-US%22%3ERe%3A%20Multi-year%20Budgets%20vs.%20Allocations%20Power%20Pivot%20Table%20(from%202%20different%20Excel%20tables)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2356902%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1029263%22%20target%3D%22_blank%22%3E%40Adam_Algar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20variant%3A%3C%2FP%3E%0A%3CP%3E-%20query%20both%20tables%3C%2FP%3E%0A%3CP%3E-%20remove%20rows%20with%20Totals%3C%2FP%3E%0A%3CP%3Ereference%20them%2C%20and%20for%20each%3C%2FP%3E%0A%3CP%3E-%20not%20to%20lost%20years%20without%20data%20replace%20null%20on%200%2C%20since%20number%20of%20columns%20is%20flexible%20use%20Table.ColumnNames()%20as%20list%20of%20columns%20to%20replace%3C%2FP%3E%0A%3CP%3E-%20unpivot%20other%20than%20budget%20columns%3C%2FP%3E%0A%3CP%3E-%20remove%20records%20which%20contains%20%22total%22%20(removing%20former%20rows%20totals)%3C%2FP%3E%0A%3CP%3E-%20change%20back%200%20on%20null%3C%2FP%3E%0A%3CP%3Egenerate%20list%20of%20years%20in%20case%20if%20it%20is%20different%20in%20both%20tables%3C%2FP%3E%0A%3CP%3E-%20reference%20again%20initial%20tables%3C%2FP%3E%0A%3CP%3E-%20remove%20budget%20columns%3C%2FP%3E%0A%3CP%3E-%20get%20list%20of%20column%20names%20and%20convert%20to%20table%3C%2FP%3E%0A%3CP%3E-%20combine%20both%20queries%20with%20years%20and%20remove%20duplicates%3C%2FP%3E%0A%3CP%3ELoad%20unpivoted%20budgets%20and%20years%20into%20data%20model%3C%2FP%3E%0A%3CP%3Ecreate%20relationships%20as%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20539px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280848i1BB50831750E76FC%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eadd%20DAX%20measures%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EAllocated%20Budget%3A%3DSUM(Allocations%5BAllocated%5D)%0A%0AAvailable%20Budget%3A%3DCALCULATE%20(%0A%20%20%20SUM(AvailableBudgets%5BAvailable%5D)%2C%0A%20%20%20TREATAS(VALUES(Allocations%5BBudget%20source%5D)%2CAvailableBudgets%5BBudget%20source%5D)%0A%20%20%20)%0A%0ARemaining%20Budget%3A%3D%5BAvailable%20Budget%5D-%5BAllocated%20Budget%5D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eapply%20proper%20formatting%20to%20measures%3C%2FP%3E%0A%3CP%3EBuild%20PivotTable%20from%20data%20model%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20596px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280849i6803568925429911%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eit%20is%20in%20the%20second%20sheet%20attached.%3C%2FP%3E%0A%3CP%3EI'm%20not%20sure%20how%20it%20works%20on%20Excel%202016%20on%20Win7%2C%20both%20are%20outdated%20with%20limited%20or%20no%20support%2C%20at%20least%20without%20features%20update.%20But%20you%20may%20try.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2368386%22%20slang%3D%22en-US%22%3ERe%3A%20Multi-year%20Budgets%20vs.%20Allocations%20Power%20Pivot%20Table%20(from%202%20different%20Excel%20tables)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2368386%22%20slang%3D%22en-US%22%3EThanks%20very%20much%20for%20this%20detailed%20response.%20I%20have%20tried%20it%2C%20and%20while%20I%20am%20sure%20it%20would%20work%20in%20newer%20%2F%20updated%20versions%2C%20it%20sadly%20seems%20to%20fall%20apart%20at%20the%20%22treatas%22%20DAX%20part%2C%20meaning%20it%20doesn't%20exist%20in%20my%20version.%20Not%20likely%20to%20be%20able%20to%20resolve%20this%20version%20problem%20any%20time%20soon%20unfortunately.%3CBR%20%2F%3E%3CBR%20%2F%3EGreat%20response%20though%2C%20thanks%20again!%3C%2FLINGO-BODY%3E
New Contributor

Hello all,

 

Long time excel user, first time poster.  

 

I have attached example tables to facilitate an understanding of what I am trying to do. I am rather new to Power Pivot, Power Query (Get&Transform) and all of the wonderful features, but I am very familiar with Excel in general, and feel very comfortable learning new things. I have been successful in creating power pivot tables and using power query features, and have created bridging tables of unique entries in my own data models to help combine information to within single tables. 

 

On to the problem: I have two separate Excel tables, one tracking available Budgets year over year, and the other tracking allocations of funding to recipients, traceable back to the Budget reference titles (read: "Budget source" column in each table). The tables need to remain separate, and years need to remain as columns, not rows. However, there is a great deal of flexibility otherwise. 

 

Overall, I am trying to create a Power Pivot table that will easily update itself and show year-over-year budget amounts per budget, total allocations from said budget, and the variance (surplus/unspent or deficit). 

 

I have added both tables to the data model, and a relationship can be drawn using "Budget source" column. However, I cannot seem to create a power pivot table that will show each budget's available amounts in one row, followed immediately by allocations from said budget in the second row, and then a variance equation automatically calculating whether there is any remaining money (surplus/unspent) or if it is oversubscribed (deficit). 

 

I hope the attachment provides sufficient information. I have explained perhaps better in the notes boxes under each table what I am trying to do. I am sure this is doable, I am just not advanced enough in my understanding. 

 

Other info:

  • Device and OS platform: PC, Windows 7 Enterprise
  • Excel product name and version number: MS Excel Professional Plus 2016 (16.0.5149.1000), 32bit.

Thank you ahead of time for your help and perspectives. Cheers!

Adam

 

 

 

5 Replies
I think the only way to do that is not through power pivot because the power in the power pivot is in creating relationships (one to many). With many to many your only recourse is to unpivot both tables in power query then merge append both tables then add a designation column to id which data is a budget data and which data is the allocation data to differentiate them, then create a normal pivot table to summarize them. the budget id will go in column as well as the designation (i.e Budget, Allocation, and the total between the two will be the variance have to make the allocation a negative number though

@Adam_Algar 

As variant:

- query both tables

- remove rows with Totals

reference them, and for each

- not to lost years without data replace null on 0, since number of columns is flexible use Table.ColumnNames() as list of columns to replace

- unpivot other than budget columns

- remove records which contains "total" (removing former rows totals)

- change back 0 on null

generate list of years in case if it is different in both tables

- reference again initial tables

- remove budget columns

- get list of column names and convert to table

- combine both queries with years and remove duplicates

Load unpivoted budgets and years into data model

create relationships as

image.png

add DAX measures as

Allocated Budget:=SUM(Allocations[Allocated])

Available Budget:=CALCULATE (
   SUM(AvailableBudgets[Available]),
   TREATAS(VALUES(Allocations[Budget source]),AvailableBudgets[Budget source])
   )

Remaining Budget:=[Available Budget]-[Allocated Budget]

apply proper formatting to measures

Build PivotTable from data model

image.png

it is in the second sheet attached.

I'm not sure how it works on Excel 2016 on Win7, both are outdated with limited or no support, at least without features update. But you may try.

Thanks very much for this detailed response. I have tried it, and while I am sure it would work in newer / updated versions, it sadly seems to fall apart at the "treatas" DAX part, meaning it doesn't exist in my version. Not likely to be able to resolve this version problem any time soon unfortunately.

Great response though, thanks again!

@Adam_Algar 

If TREATAS is not supported by your version you may use some equivalent

Available Budget Variant:=CALCULATE (
   SUM(AvailableBudgets[Available]),
   FILTER( ALL(AvailableBudgets[Budget source]),
           CONTAINS(
              VALUES(Allocations[Budget source]),
              Allocations[Budget source],
              AvailableBudgets[Budget source]))
   )

It returns the same result

image.png

CONTAINS shall be available, that's quite old function.