Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Custom Column to return a value based on matching variable

I want a custom column that returns the Canada value if the variable matches

Thank you!!

 

RegionVariableValueCustom Column

Canada

A

10

10

Canada

B2020
OntarioA3010
OntarioB4020
AlbertaA5010
AlbertaB6020
B-CA7010
  • Anonymous ,

    Hope this will resolve your issue:

    CustomColumn = 
    VAR _Var = [Variable]
    VAR _Value = CALCULATE( MAX( YourTable[Value] ), 
                        FILTER( YourTable, YourTable[Region] = "Canada" && YourTable[Variable] = _Var ))
    
    RETURN
        _Value

    Regards,

3 Replies

  • rsbin's avatar
    rsbin
    Community Champion

    Anonymous ,

    Hope this will resolve your issue:

    CustomColumn = 
    VAR _Var = [Variable]
    VAR _Value = CALCULATE( MAX( YourTable[Value] ), 
                        FILTER( YourTable, YourTable[Region] = "Canada" && YourTable[Variable] = _Var ))
    
    RETURN
        _Value

    Regards,

    • Anonymous's avatar
      Anonymous
      Not applicable

      Works perfectly, thank you!

  • sorry I dont understand "I want a custom column that returns the Canada value if the variable matches"

    please give example of desired output from the above example. thanks