Forum Discussion

Milozebre's avatar
Milozebre
Helper V
6 years ago
Solved

Use variable in measure

Hello Community, 

 

I hope you are well and that containment is not too difficult.

I have a problem with the parameters and my measurements.

I am doing my math class and I would like to make a variable that to an extent that calculates according to my choice.

The best thing would be for me to make this choice as soon as I open my file pbit, but if this is not possible then choose from the file. Example if I chose the Poisson distribution, then I calculate (formula or another measure), if I chose another, then another calculation. I watched videos on youtube on selectedvalue with switch but I can't

Here is my formul in Excel and its works

=SI(GAUCHE(CV_calculation_rule;1)="1";CK2;(SI(GAUCHE(CV_calculation_rule;1)="2";CL2;SI(GAUCHE(CV_calculation_rule;1)="4";CM2;RECHERCHEV(A2;'Comp database'!A:V;22;0)))))

CV_calculation_rule is my list

CK2, CL2, CM2 are column with formule that I can do in power bi. 

 

Thank you 

 

  • Hi Milozebre

     

    You can modify your formula as below:

     

    Measure = SWITCH(SELECTVALUE(SI(GAUCHE(CV_calculation_rule;1)),"1";SELECTEDVALUE(CK2);
    "2";SELECTEDVALUE(CL2);"4";SELECTEDVALUE(CM2);RECHERCHEV(A2;'Comp database'!A:V;22;0))

     

    I'm not sure what does "SI""GAUCHE""RECHERCHEV"mean?Are they all tables' names?The measure can be simply described as :

     

    measure= SWITCH([measure],"case 1","value 1","case 2,"value 2",...[else])

     

     

    Best Regards,
    Kelly
    Did I answer your question? Mark my post as a solution!

     

9 Replies

  • VijayP's avatar
    VijayP
    Community Champion

    You can use Same formula in power bi what you have used in Excel . What is the difficulty you are facing please let me know

    Regards

    Vijay Perepa

  • v-kelly-msft's avatar
    v-kelly-msft
    Community Support

    Hi Milozebre

     

    You can modify your formula as below:

     

    Measure = SWITCH(SELECTVALUE(SI(GAUCHE(CV_calculation_rule;1)),"1";SELECTEDVALUE(CK2);
    "2";SELECTEDVALUE(CL2);"4";SELECTEDVALUE(CM2);RECHERCHEV(A2;'Comp database'!A:V;22;0))

     

    I'm not sure what does "SI""GAUCHE""RECHERCHEV"mean?Are they all tables' names?The measure can be simply described as :

     

    measure= SWITCH([measure],"case 1","value 1","case 2,"value 2",...[else])

     

     

    Best Regards,
    Kelly
    Did I answer your question? Mark my post as a solution!

     

    • Milozebre's avatar
      Milozebre
      Helper V

      Hello v-kelly-msft 

       

      Thank you for your reply. 

       

      In english its = If(Left(CV_calculation_rule) = "1",CK3;(SI(Left(CV_calculation_rule)="2";CL3;IF(Left(CV_calculation_rule) ="4", CM3;(Vlookup(A3;'Comp database'!A:V;22;0))))

       

      CV_calculation-rule = name of my list

      CK3, CL3, CM3 = columns

      Comp database = name of a sheet.

       

      In my case, I dont have the sheet in Power BI 

       

      If I selected 1 from my parameter then do (columnA * Column B or a measure who do that); If I selected 2 from parameter then do  (another calcul or measure), ...

       

      I have only 4 choices.

      And I'm talking about a parameter, but is it really a parameter that I have to do? And if so, is it a parameter that I create so that it is requested at startup (Transform Data - Manage parameter) or Modeling New parameter what if

       

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    So, you could have a page that displays that presents a slicer of the options you have and then that drives everything else. Or buttons that act as choices to bookmarks.

     

    Difficult to really understand what you are going for here.

  • Dear community, 

     

    I close my request without having had the answer to my question following a message from a member, he will recognize himself.

    I thank the two people who took the time to answer me. It is a community but apparently for some reserved for a certain category of people with a level other than mine.

     

    Stay safe,

     

     

    • Greg_Deckler's avatar
      Greg_Deckler
      Community Champion
      Milozebre , Not all questions are answerable. Seems like you had 3 people attempt to help. It's only been a day!
      • Milozebre's avatar
        Milozebre
        Helper V

        you want an explanation on the forum?

        OK.

        Two people tried to help me and I thanked them.

        You, with your habit, you don't answer, a track in the vague or then to read a page of the forum to be made help faster but then, one does not see you any more.

        I sent you a message already. I haven't said anything before.

        I imagine all the people who are waiting for help and who are reading you.

        You may be good, but your pedagogy is not intended for the audience.

        If I find the solution, this will be your 121 DAX recipes.

         

        And saying hello never killed anyone.

         

        Have a nice day.