Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Take values from a column based on a value.

Hey all,

 

Short question. I think this should be easy, but my peanut brain can't figure it out.

 

I have a measure formula that results in either A, B or C.

How do I write another measure that gives me [Antwoord] 1, 2 or 3, depending on whether my formula is A, B, or C?

 

So what I'm looking for, is a measure that will give me answer 1 if my other measure is "A". If my other measure is "B", I need to return answer 2.

 

 

Thanks!

4 Replies

  • Hey Anonymous,

     

       Thanks for reaching out, there a few ways to go about this but a calculated column may be the simpliest way.

     

       Here is the sample data I am using

     

     

    If you create a calculate column that looks like this

     

    Antewoord =
    
    IF('Test Data'[Code] = "A", 1,
    IF('Test Data'[Code] = "B", 2,
    IF('Test Data'[Code] = "C", 3)))

     

    That will result in data that looks like this

     

     

     

    Let us know if this meets your need, if not we can try another solution!

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hey westwrightj 

       

      Sorry for not being clear in my original post. In my example the values in [antwoord] are not actually 1,2 or 3. They are just placeholder to show the example!

       

      Your example is hardcoded, but sadly that won't work because I have a lot more questions and answers. For that reason, I'm looking for a formula does the follownig:

       

      If my other measure is A, then filter out all rows where [code] is not A.

       

      i hope that makes sense. I think my explaintaion is not the best 😄

  • V-lianl-msft's avatar
    V-lianl-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Convert the measure you create into calculated table and use it as a slicer.

    Then create a measure and apply it to visual level filter with measure =1.

    measure = if([measure]=selectedvalue(table2[code]),1)

    If the problem persists,could you share the sample pbix via cloud service like onedrive for business?

    Please mask any sensitive data before uploading

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.