Forum Discussion

Orstenpowers's avatar
Orstenpowers
Post Patron
2 years ago
Solved

Measure does not work with "string" values

Dear all,

I have a problem with the measure below. I know that it does work when I want to return numeric values. I had found this great switching metrics in the web.

However, this time the measure should return values that are of type "string" and as I already understood, for this purpose using "SUM" does not work.

 

With my dashboard, I would like to select from a slicer OPTION 01 or OPTION 02 or OPTION 03 or.......

The measure below then should be integrated into a table or matrix visual and return all applicable string values.

Please refer to the screenshot attached. From the slicer at the top I would like to select one option and in return, the second visual should return all applicable string values. (in this case the available languages of documentation)..



Is there any chance to adjust the measure that it will work???

 
Measure Selected =
IF(
    HASONEVALUE('Measure Table'[Measure]),
        SWITCH(
            VALUES('Measure Table'[Measure]),
                "Option 01",SUM(Base_Data[PCF_Option_01]),
                "Option 02",SUM(Base_Data[PCF_Option_02]),
                "Option 03",SUM(Base_Data[PCF_Option_03]),
                SUM(Base_Data[- Net Amount])))
 
I am confident that someone here can help me. Hopefully, as I am lost. 😞
  • Hi Anonymous ,

     

    On https://www.phdata.io/blog/switching-metrics-in-power-bi/  I had found a blog that explained the setup of a switching metrics.

    This was quite interesting and I tried…and it worked. From now I had – on the one hand – a nice slicer that allowed me to select between EUR currency, local currency and order quantity and -on the other hand – another visual that automatically changed from EUR to local currency or quantity. So far, so good!

     

    Now it is my intention to adjust this switching approach.

    The slicer that is based on a table that I had to create manually, should allow me to select specific options that our instruments can be built off.

    Our instruments consists of a model code that can comprise of up to 32 different features and for each of these features you can select one option.

    Let’s say the model code is VR1C9K7HD4100LTRXA131WA0…and I would like to know details about feature 10 (10th position of the model code).

     

    From my slicer I would like to select e.g. “Option 10” and another visual (table or matrix) should list all available options as I had tried to explain with my original posting.

     

    So the measure that I am looking for should return rather text than figures, as my sample data should show.

    Sorry, if my explanation did confuse you…

13 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Orstenpowers ,

     

    Try changing the sum part of the expression to:

    SUMX('Base_Data',VALUE('Base_Data'[PCF_Option_01]))
    This way it will be output as a numeric value
     

     

    Hope it helps!

     

    Best regards,
    Community Support Team_ Scott Chang

     

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

     

    • Orstenpowers's avatar
      Orstenpowers
      Post Patron

      Hi Anonymous ,

       

      Thanks for your valuable feedback!
      I changed my measure accordingly, but unfortunately I get the following error message:

      It states that type "Text" cannot be converted into type "Number".

       

      Do you have any idea what else I could do?

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Orstenpowers ,

         

        I can't think of any other way, can you make the columns number by power query?

         

        Best regards,
        Community Support Team_ Scott Chang