Calculate a date according slicers chosen





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I need your help on PowerBI. I'd like to calculate something according to the slicers chosen by the user. I read that what I wanted to do at first is impossible (I wanted to add a calculated column according to the slicers chosen by the user) but maybe you will find me another way to succeed. Let me explain.



I have 2 tables, not related.



Table 1 will be used to add 3 slicers: slicer Category, slicer Type, slicer Rp.



Category Type Rp
c1 A X
c1 B X
c2 C X
c2 D Y


Table 2 will contain my data (my dates are formatted in dd/mm/yyyy).



ID  TheoreticalDeadline RealDeadline    Done    Type _A Type _B Type _C Type _D
Abc 01/05/2018 02/05/2018 Y 5 0 0 3
Def 05/04/2018 05/04/2018 Y 0 0 2 0
Ghi 12/03/2018 18/03/2018 N 0 0 0 1


I have made the following measures (which works fine):



Done_Where = if(Table2[Done]="Y"; 1; 0)

DoneGood_Where=if(Table2[Done]="Y";
if(Table2[RealDeadline]<=Table2[TheoreticalDeadline]; 1; 0))

Result1 = SUM(Table2[DoneGood_Where])/sum(Table2[Done_Where])


In my example, Result1 = 1 /2 because:





  • Def has RealDeadline equal than TheoreticalDeadline


  • Ghi has Done = N so is not taken into account


I want to make a Result2 which will depend on the user choices.



Result2 = SUM(Table2[DoneGood_WhereSelected])/sum(Table2[Done_Where])


And the problem is to compute DoneGood_WhereSelected. I would like something like this:



DoneGood_WhereSelected =
if(Table2[Done]="Y"; if(Table2[RealDeadline]<=Table2[TheoreticalDeadline] +
values from Table2 stored in the columns for which the user has clicked;1;0))


For instance, if the user click on the slicer Resp=X, then:




  • For Abc: TheoreticalDeadline + 5 (because Type_A belongs to X) = 06/05/2018

  • For Def: TheoreticalDeadline + 2 (because Type_C belongs to X) = 07/04/2018


And then Result2 = 2/2 because:





  • Abc and Def have RealDeadline < TheoreticalDeadline + values stored


In my example, the user clicks only on one checkbox of one slicer, but in reality, I'd like to authorize him to make multiple selections on the different slicers (example: the user click Rp=X and (Type=A or Type=B). In real life, I have 15 Types, 5 categories, and 2 Rp, so it's not optimized to compute every possible combination when loading data.



So, what kind of formulas could I use?










share|improve this question































    0















    I need your help on PowerBI. I'd like to calculate something according to the slicers chosen by the user. I read that what I wanted to do at first is impossible (I wanted to add a calculated column according to the slicers chosen by the user) but maybe you will find me another way to succeed. Let me explain.



    I have 2 tables, not related.



    Table 1 will be used to add 3 slicers: slicer Category, slicer Type, slicer Rp.



    Category Type Rp
    c1 A X
    c1 B X
    c2 C X
    c2 D Y


    Table 2 will contain my data (my dates are formatted in dd/mm/yyyy).



    ID  TheoreticalDeadline RealDeadline    Done    Type _A Type _B Type _C Type _D
    Abc 01/05/2018 02/05/2018 Y 5 0 0 3
    Def 05/04/2018 05/04/2018 Y 0 0 2 0
    Ghi 12/03/2018 18/03/2018 N 0 0 0 1


    I have made the following measures (which works fine):



    Done_Where = if(Table2[Done]="Y"; 1; 0)

    DoneGood_Where=if(Table2[Done]="Y";
    if(Table2[RealDeadline]<=Table2[TheoreticalDeadline]; 1; 0))

    Result1 = SUM(Table2[DoneGood_Where])/sum(Table2[Done_Where])


    In my example, Result1 = 1 /2 because:





    • Def has RealDeadline equal than TheoreticalDeadline


    • Ghi has Done = N so is not taken into account


    I want to make a Result2 which will depend on the user choices.



    Result2 = SUM(Table2[DoneGood_WhereSelected])/sum(Table2[Done_Where])


    And the problem is to compute DoneGood_WhereSelected. I would like something like this:



    DoneGood_WhereSelected =
    if(Table2[Done]="Y"; if(Table2[RealDeadline]<=Table2[TheoreticalDeadline] +
    values from Table2 stored in the columns for which the user has clicked;1;0))


    For instance, if the user click on the slicer Resp=X, then:




    • For Abc: TheoreticalDeadline + 5 (because Type_A belongs to X) = 06/05/2018

    • For Def: TheoreticalDeadline + 2 (because Type_C belongs to X) = 07/04/2018


    And then Result2 = 2/2 because:





    • Abc and Def have RealDeadline < TheoreticalDeadline + values stored


    In my example, the user clicks only on one checkbox of one slicer, but in reality, I'd like to authorize him to make multiple selections on the different slicers (example: the user click Rp=X and (Type=A or Type=B). In real life, I have 15 Types, 5 categories, and 2 Rp, so it's not optimized to compute every possible combination when loading data.



    So, what kind of formulas could I use?










    share|improve this question



























      0












      0








      0








      I need your help on PowerBI. I'd like to calculate something according to the slicers chosen by the user. I read that what I wanted to do at first is impossible (I wanted to add a calculated column according to the slicers chosen by the user) but maybe you will find me another way to succeed. Let me explain.



      I have 2 tables, not related.



      Table 1 will be used to add 3 slicers: slicer Category, slicer Type, slicer Rp.



      Category Type Rp
      c1 A X
      c1 B X
      c2 C X
      c2 D Y


      Table 2 will contain my data (my dates are formatted in dd/mm/yyyy).



      ID  TheoreticalDeadline RealDeadline    Done    Type _A Type _B Type _C Type _D
      Abc 01/05/2018 02/05/2018 Y 5 0 0 3
      Def 05/04/2018 05/04/2018 Y 0 0 2 0
      Ghi 12/03/2018 18/03/2018 N 0 0 0 1


      I have made the following measures (which works fine):



      Done_Where = if(Table2[Done]="Y"; 1; 0)

      DoneGood_Where=if(Table2[Done]="Y";
      if(Table2[RealDeadline]<=Table2[TheoreticalDeadline]; 1; 0))

      Result1 = SUM(Table2[DoneGood_Where])/sum(Table2[Done_Where])


      In my example, Result1 = 1 /2 because:





      • Def has RealDeadline equal than TheoreticalDeadline


      • Ghi has Done = N so is not taken into account


      I want to make a Result2 which will depend on the user choices.



      Result2 = SUM(Table2[DoneGood_WhereSelected])/sum(Table2[Done_Where])


      And the problem is to compute DoneGood_WhereSelected. I would like something like this:



      DoneGood_WhereSelected =
      if(Table2[Done]="Y"; if(Table2[RealDeadline]<=Table2[TheoreticalDeadline] +
      values from Table2 stored in the columns for which the user has clicked;1;0))


      For instance, if the user click on the slicer Resp=X, then:




      • For Abc: TheoreticalDeadline + 5 (because Type_A belongs to X) = 06/05/2018

      • For Def: TheoreticalDeadline + 2 (because Type_C belongs to X) = 07/04/2018


      And then Result2 = 2/2 because:





      • Abc and Def have RealDeadline < TheoreticalDeadline + values stored


      In my example, the user clicks only on one checkbox of one slicer, but in reality, I'd like to authorize him to make multiple selections on the different slicers (example: the user click Rp=X and (Type=A or Type=B). In real life, I have 15 Types, 5 categories, and 2 Rp, so it's not optimized to compute every possible combination when loading data.



      So, what kind of formulas could I use?










      share|improve this question
















      I need your help on PowerBI. I'd like to calculate something according to the slicers chosen by the user. I read that what I wanted to do at first is impossible (I wanted to add a calculated column according to the slicers chosen by the user) but maybe you will find me another way to succeed. Let me explain.



      I have 2 tables, not related.



      Table 1 will be used to add 3 slicers: slicer Category, slicer Type, slicer Rp.



      Category Type Rp
      c1 A X
      c1 B X
      c2 C X
      c2 D Y


      Table 2 will contain my data (my dates are formatted in dd/mm/yyyy).



      ID  TheoreticalDeadline RealDeadline    Done    Type _A Type _B Type _C Type _D
      Abc 01/05/2018 02/05/2018 Y 5 0 0 3
      Def 05/04/2018 05/04/2018 Y 0 0 2 0
      Ghi 12/03/2018 18/03/2018 N 0 0 0 1


      I have made the following measures (which works fine):



      Done_Where = if(Table2[Done]="Y"; 1; 0)

      DoneGood_Where=if(Table2[Done]="Y";
      if(Table2[RealDeadline]<=Table2[TheoreticalDeadline]; 1; 0))

      Result1 = SUM(Table2[DoneGood_Where])/sum(Table2[Done_Where])


      In my example, Result1 = 1 /2 because:





      • Def has RealDeadline equal than TheoreticalDeadline


      • Ghi has Done = N so is not taken into account


      I want to make a Result2 which will depend on the user choices.



      Result2 = SUM(Table2[DoneGood_WhereSelected])/sum(Table2[Done_Where])


      And the problem is to compute DoneGood_WhereSelected. I would like something like this:



      DoneGood_WhereSelected =
      if(Table2[Done]="Y"; if(Table2[RealDeadline]<=Table2[TheoreticalDeadline] +
      values from Table2 stored in the columns for which the user has clicked;1;0))


      For instance, if the user click on the slicer Resp=X, then:




      • For Abc: TheoreticalDeadline + 5 (because Type_A belongs to X) = 06/05/2018

      • For Def: TheoreticalDeadline + 2 (because Type_C belongs to X) = 07/04/2018


      And then Result2 = 2/2 because:





      • Abc and Def have RealDeadline < TheoreticalDeadline + values stored


      In my example, the user clicks only on one checkbox of one slicer, but in reality, I'd like to authorize him to make multiple selections on the different slicers (example: the user click Rp=X and (Type=A or Type=B). In real life, I have 15 Types, 5 categories, and 2 Rp, so it's not optimized to compute every possible combination when loading data.



      So, what kind of formulas could I use?







      powerbi dax






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 17:18









      Alexis Olson

      15.4k22136




      15.4k22136










      asked Nov 16 '18 at 14:20









      mdlmmdlm

      11




      11
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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',
          autoActivateHeartbeat: false,
          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%2fstackoverflow.com%2fquestions%2f53339652%2fcalculate-a-date-according-slicers-chosen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53339652%2fcalculate-a-date-according-slicers-chosen%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

          List item for chat from Array inside array React Native

          Thiostrepton

          Caerphilly