cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Milozebre
Helper V
Helper V

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 

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
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!

 

View solution in original post

9 REPLIES 9
Milozebre
Helper V
Helper V

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,

 

 

@Milozebre , Not all questions are answerable. Seems like you had 3 people attempt to help. It's only been a day!

@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

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. 

You seem mad at me about something @Milozebre , I am not sure why. I try to answer questions as best I can and have been doing it for like 5 years now. I have over 2,500 confirmed solutions authored so some people seem to find what I post valuable. I replied to your private message.

@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

In the hopes others may benefit:

 

I suggested using a slicer or buttons. If you use a slicer, you would do something like create a slicer table like:

 

Choices

Options
Option1
Option2
Option3
Option4

 

And then a measure like:

 

Measure = 

  SWITCH('Choices'[Option],

    "Option1",<some calculation>,

    "Option2",<some other calculation>,

    "Option3",<some other other calculation>,

    "Option4",<some other other other calculation>

  )

 

So, for the <some calculation> stuff, those would be good if each of those was a separate measure that handled it.

 

I am still not sure I understand the actual question though or what you are going for. 

 


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition
Greg_Deckler
Super User
Super User

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.


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition
v-kelly-msft
Community Support
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!

 

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

 

VijayP
Super User
Super User

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




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May 23 2022 episode 5 with aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt will talk about the importance of Data Modeling.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!