Forum Discussion
how to make column optional / selective
Hello, so I have a line graph. on the y-axis is a set of data set by a spesific unit. I would like to be able to switch from the current unit of data to a diffrent unit of data, is there a way to change over without editing in the visualizations tab under " Values". Currently I have created two columns that convert the data to one unit or the other manualy .
End goal is to let the user choose what units they would like to see the data presented in , ex: inches or cm.
All help is great! thanks.
- Collin
- Anonymous7 years ago
Ok , so i figured it out! it was way more simple that what we were trying. I noticed you were using
VAR amount=sum(""Column"") to basicaly transfer a column, so i did thisBar/Line Value =VAR mAamount = SUM('BCI - id 1,3,6,7,8'[mA])VAR amount=SUM('BCI - id 1,3,6,7,8'[dBuA])returnIF(selectedvalue(Table1[Units]) ="dBuA", amount,IF(selectedvalue(Table1[Units]) ="mA" , mAamount,0))I created two columns one for each unit that calulated the number correctly. Then the code imports them depending on what is selected. Here are the two calculated columns::dBuA = IF((NOT('BCI - id 1,3,6,7,8'[Unit] = "dBuA")) , 20 * LOG10('BCI - id 1,3,6,7,8'[RequirementLevel]) + 60 ,'BCI - id 1,3,6,7,8'[RequirementLevel])mA = IF((NOT('BCI - id 1,3,6,7,8'[Unit] = "mA")), (POWER(10,(( 'BCI - id 1,3,6,7,8'[RequirementLevel] - 60)/20))),'BCI - id 1,3,6,7,8'[RequirementLevel])"front end" table to select what unit to display "back end" the tablethanks for the help , hope this explanation is not as confusing
13 Replies
- ryan_mayuSuper User
Anonymous
I created two tables to test.
measure = VAR meterchangerate=CALCULATE(SELECTEDVALUE(Sheet10[CHANGE RATE]),FILTER(Sheet10,Sheet10[UNIT]="meter")) VAR decimetre=CALCULATE(SELECTEDVALUE(Sheet10[CHANGE RATE]),FILTER(Sheet10,Sheet10[UNIT]="decimetre")) VAR cm=CALCULATE(SELECTEDVALUE(Sheet10[CHANGE RATE]),FILTER(Sheet10,Sheet10[UNIT]="cm")) VAR amount=sum(Sheet9[AMOUNT]) return if(SELECTEDVALUE(Sheet10[UNIT])="meter",amount*meterchangerate,if(SELECTEDVALUE(Sheet10[UNIT])="decimetre",amount*decimetre,if(SELECTEDVALUE(Sheet10[UNIT])="cm",amount*cm)))
You can create a measure and filter unit to change the value.
- AnonymousNot applicable
Thankyou for the responce, it kind of makes sense, but how exectly are you doing your calculations to go from 2 to 20.
the calculations im using are alittle more complex, here are the two i need.
mA to dBuA = 20 * LOG10( table1'[ to dBuA] ) + 60dBuA to mA = POWER(10,(( table1'[ to mA] - 60)/20))thanks for the help.-Collin- ryan_mayuSuper User
Anonymous
2 or 20 depends on what unit you choose. That's why you see two tables. One is created for unit conversion. You stored all the units in that table. It will automatically pick out the corresponding conversion rate when end users choose one unit.
Will the number of 20 will changed in your DAX? Maybe you can modify the coding like something below
mA to dBuA =VAR unitonerate=calculate(selectedvalue(.....) -- when end user choose unit one, what conversion rate will beVAR unittworate=calculate(selectedvalue(...) -- when end user choose unit two, what conversion rate will beVAR unitthreerate=calculate(selectedvalue(...) -- when end user choose unit three, what conversion rate will beReturnif(selectedvalue ()="UnitOne", unitonerate* LOG10( table1'[ to dBuA] ) + 60, -- use unitone conversion rate in the calculationif(selectedvalue()="UnitTwo", unittworate* LOG10( table1'[ to dBuA] ) + 60, -- use unittwo conversion rate in the calculationif(selectedvalue()="UnitThree",unitthreerate** LOG10( table1'[ to dBuA] ) + 60, --use unitthree conversion rate in the calculationThe coding is not completed. You need to modify it.Please let me know if you have any other questions. Thanks