Create a measure to calculate a variable number of columns











up vote
0
down vote

favorite












I have an ODATA data source that, simplified, has the following columns:




Name

LifetimeBudget

FY2016Budget

FY2017Budget

...

FY2070Budget




I want to create a pivot table that will display the fields above in the following order:




Name, FYxxxxBudget, ..., FYxxxxBudget, SelectedYearsBudget,
LifetimeBudget




The FYxxxxBudgets are a range where the user can select which years they are interested in and the SelectedYearsBudget column would display a calculated total for only the included years (where LifetimeBudget is from the datasource, but contains the total budget over all years in the table - this can be recreated as a calculated field if it helps).



For example:



Name    FY2020Budget    FY2021Budget  FY2022Budget    SelectedYearsBudget    LifetimeBudget
HR $200,000 $200,000 $210,000 $610,000 $2,000,000
IT $300,000 $300,000 $310,000 $910,000 $3,000,000


And so on. If the user adds the FY2023Budget column, SelectedYearsBudget changes to reflect the new column in its total. Further, SelectedYearsBudget will be used as a filter (we don't care to see any items where SelectedYearsBudget is 0).



Doing this as a single pivot table is ideal, but if intermediate pivot tables are needed, or some VB coding, or a display page pulling values from the table with LOOKUP or other reference functions is needed, that is okay - my current solution is a Frankenstein's Monster of all of the above (except VBA) with the problem being that the intermediate table doesn't update when underlying filters change.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I have an ODATA data source that, simplified, has the following columns:




    Name

    LifetimeBudget

    FY2016Budget

    FY2017Budget

    ...

    FY2070Budget




    I want to create a pivot table that will display the fields above in the following order:




    Name, FYxxxxBudget, ..., FYxxxxBudget, SelectedYearsBudget,
    LifetimeBudget




    The FYxxxxBudgets are a range where the user can select which years they are interested in and the SelectedYearsBudget column would display a calculated total for only the included years (where LifetimeBudget is from the datasource, but contains the total budget over all years in the table - this can be recreated as a calculated field if it helps).



    For example:



    Name    FY2020Budget    FY2021Budget  FY2022Budget    SelectedYearsBudget    LifetimeBudget
    HR $200,000 $200,000 $210,000 $610,000 $2,000,000
    IT $300,000 $300,000 $310,000 $910,000 $3,000,000


    And so on. If the user adds the FY2023Budget column, SelectedYearsBudget changes to reflect the new column in its total. Further, SelectedYearsBudget will be used as a filter (we don't care to see any items where SelectedYearsBudget is 0).



    Doing this as a single pivot table is ideal, but if intermediate pivot tables are needed, or some VB coding, or a display page pulling values from the table with LOOKUP or other reference functions is needed, that is okay - my current solution is a Frankenstein's Monster of all of the above (except VBA) with the problem being that the intermediate table doesn't update when underlying filters change.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an ODATA data source that, simplified, has the following columns:




      Name

      LifetimeBudget

      FY2016Budget

      FY2017Budget

      ...

      FY2070Budget




      I want to create a pivot table that will display the fields above in the following order:




      Name, FYxxxxBudget, ..., FYxxxxBudget, SelectedYearsBudget,
      LifetimeBudget




      The FYxxxxBudgets are a range where the user can select which years they are interested in and the SelectedYearsBudget column would display a calculated total for only the included years (where LifetimeBudget is from the datasource, but contains the total budget over all years in the table - this can be recreated as a calculated field if it helps).



      For example:



      Name    FY2020Budget    FY2021Budget  FY2022Budget    SelectedYearsBudget    LifetimeBudget
      HR $200,000 $200,000 $210,000 $610,000 $2,000,000
      IT $300,000 $300,000 $310,000 $910,000 $3,000,000


      And so on. If the user adds the FY2023Budget column, SelectedYearsBudget changes to reflect the new column in its total. Further, SelectedYearsBudget will be used as a filter (we don't care to see any items where SelectedYearsBudget is 0).



      Doing this as a single pivot table is ideal, but if intermediate pivot tables are needed, or some VB coding, or a display page pulling values from the table with LOOKUP or other reference functions is needed, that is okay - my current solution is a Frankenstein's Monster of all of the above (except VBA) with the problem being that the intermediate table doesn't update when underlying filters change.










      share|improve this question













      I have an ODATA data source that, simplified, has the following columns:




      Name

      LifetimeBudget

      FY2016Budget

      FY2017Budget

      ...

      FY2070Budget




      I want to create a pivot table that will display the fields above in the following order:




      Name, FYxxxxBudget, ..., FYxxxxBudget, SelectedYearsBudget,
      LifetimeBudget




      The FYxxxxBudgets are a range where the user can select which years they are interested in and the SelectedYearsBudget column would display a calculated total for only the included years (where LifetimeBudget is from the datasource, but contains the total budget over all years in the table - this can be recreated as a calculated field if it helps).



      For example:



      Name    FY2020Budget    FY2021Budget  FY2022Budget    SelectedYearsBudget    LifetimeBudget
      HR $200,000 $200,000 $210,000 $610,000 $2,000,000
      IT $300,000 $300,000 $310,000 $910,000 $3,000,000


      And so on. If the user adds the FY2023Budget column, SelectedYearsBudget changes to reflect the new column in its total. Further, SelectedYearsBudget will be used as a filter (we don't care to see any items where SelectedYearsBudget is 0).



      Doing this as a single pivot table is ideal, but if intermediate pivot tables are needed, or some VB coding, or a display page pulling values from the table with LOOKUP or other reference functions is needed, that is okay - my current solution is a Frankenstein's Monster of all of the above (except VBA) with the problem being that the intermediate table doesn't update when underlying filters change.







      microsoft-excel pivot-table






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 at 18:15









      cpcodes

      1013




      1013



























          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1377375%2fcreate-a-measure-to-calculate-a-variable-number-of-columns%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1377375%2fcreate-a-measure-to-calculate-a-variable-number-of-columns%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Сан-Квентин

          Алькесар

          Josef Freinademetz