cancel
Showing results for
Did you mean:
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

Accepted Solutions
Microsoft

## Re: Use variable in measure

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

9 REPLIES 9
Continued Contributor

## Re: Use variable in measure

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

Microsoft

## Re: Use variable in measure

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

Helper V

## Re: Use variable in measure

Hello @v-kelly-msft

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

Super User IV

## Re: Use variable in measure

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.

---------------------------------------

Putting square pegs in round holes since 1972.

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Datanaut!

Helper V

## Re: Use variable in measure

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,

Highlighted
Super User IV

## Re: Use variable in measure

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

---------------------------------------

Putting square pegs in round holes since 1972.

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Datanaut!

Helper V

## Re: Use variable in measure

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.

Super User IV

## Re: Use variable in measure

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.

---------------------------------------

Putting square pegs in round holes since 1972.

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Datanaut!

Super User IV

## Re: Use variable in measure

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.

---------------------------------------

Putting square pegs in round holes since 1972.

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Datanaut!

Announcements

#### Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

#### April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

#### MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors