Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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!


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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. 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
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.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.