## Desktop

Highlighted
Member
Posts: 61
Registered: ‎09-17-2018

# 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

Accepted Solutions
Member
Posts: 61
Registered: ‎09-17-2018

## Re: how to make column optional / selective

[ Edited ]

@ryan_mayu

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 this

Bar/Line Value =
VAR mAamount = SUM('BCI - id 1,3,6,7,8'[mA])
VAR amount=SUM('BCI - id 1,3,6,7,8'[dBuA])
return
IF(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 table

thanks for the help , hope this explanation is not as confusing

All Replies
Established Member
Posts: 183
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@Collin

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.

Member
Posts: 61
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@ryan_mayu

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] ) + 60
dBuA to mA  = POWER(10,(( table1'[ to mA]  - 60)/20))

thanks for the help.
-Collin
Established Member
Posts: 183
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@Collin

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 be
VAR unittworate=calculate(selectedvalue(...)  -- when end user choose unit two, what conversion rate will be
VAR unitthreerate=calculate(selectedvalue(...) -- when end user choose unit three, what conversion rate will be
Return
if(selectedvalue ()="UnitOne",  unitonerate* LOG10( table1'[ to dBuA] ) + 60,   -- use unitone conversion rate in the calculation
if(selectedvalue()="UnitTwo",  unittworate* LOG10( table1'[ to dBuA] ) + 60,  -- use unittwo conversion rate in the calculation
if(selectedvalue()="UnitThree",unitthreerate** LOG10( table1'[ to dBuA] ) + 60, --use unitthree conversion rate in the calculation

The coding is not completed. You need to modify it.

Please let me know if you have any other questions. Thanks

Member
Posts: 61
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@ryan_mayu

Hello, not sure if you saw my last post  but I have figured some things out. my only and final question is for your CHANGE RATE column you have a number. I need to use my equasion

 20 * LOG10( 'BCI - id 1,3,6,7,8'[RequirementLevel]) + 60

I tried putting this in place for the column "Change Rate" but it does not display.  here are some pictures.

this is the code that works

Here is one table

Established Member
Posts: 183
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@Collin

Is '20*LOG10('BCI-ID1,3,6,7,8'[RequirementLevel])+60' a measure?

Value =

VAR dBua=20*LOG10('BCI-ID1,3,6,7,8'[RequirementLevel])+60

VAR mA=POWER(10,(('bci-id1,3,6,7,8'[RequirementLevle])

if(selectedvalue(Table1[units])="dBua", amount*dBua,if(selectvalue(Table1[units]="mA", amount*ma))

Member
Posts: 61
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@ryan_mayu

The VAR will not let me refrence the column, is there a dax formula maybe to put it inside that would make it work?

thanks   -  Collin

Established Member
Posts: 183
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@Collin

Could you please some sample data? I am not quite sure what's the difference between my example and your data.

How you get the '20*LOG10('BCI-ID1,3,6,7,8'[RequirementLevel])', I am not familar with that.

What I have provided you is the coding in measure. You can try it by creating a measure.

Thanks

Member
Posts: 61
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@ryan_mayu

yes, sorry . the '20*LOG10('BCI-ID1,3,6,7,8'[RequirementLevel])' is the equasion to go from mA to dBuA and vice versa for the other direction, the example where you have 1, 10 , 100 is where i need these equasions. in your example your changing units by factor of 10 or 100 , im changing by these equasions

mA to dBuA - 20 * LOG10('BCI - id 1,3,6,7,8'[RequirementLevel]) + 60

dBuA to mA - POWER(10,(( 'BCI - id 1,3,6,7,8'[RequirementLevel] - 60)/20))

the  'BCI - id 1,3,6,7,8'[RequirementLevel] is simply my column of data ( your "Amount column" in your example)

Side Note :: the data entered into the column is a mix of dBuA and mA  , do I need to change all the default data to one or the other for this to work

 Requirment Level Unit 106 dBuA 100 dBuA 90 dBuA 90 dBuA 106 dBuA 106 dBuA 106 dBuA 100 dBuA 20 mA 60 mA 60 mA 33.3333 mA 100 mA 100 mA 66.6666 mA 200 mA 200 mA 90 dBuA 90 dBuA 106 dBuA 106 dBuA

here is a sample of data

the data is mixed for ease of user  adding data

thanks.

Established Member
Posts: 183
Registered: ‎09-17-2018

## Re: how to make column optional / selective

@Collin

I am not sure I understand your scenario clearly.

I create a column to converse all the unit to one. For example, I choose dBua

`dBuA = if(Sheet19[unit]="dBuA",Sheet19[requirement level],20*LOG('Sheet19'[requirement level])+60)`

Then you just create a unit table which only has mA and eBuA in order to  filter your data.

amount = sum(Sheet19[requirement level])

`change = if(SELECTEDVALUE(Unit[Unit])="dBuA",[amount],POWER(10,(([amount]-60)/20)))`