Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Cannot Convert value of type text to type true false

Hi, 

 

I know there are a lot of solutions to this topic here. Unfortunatly I can't help myself by reading them.

I wanted to do calculate formula to get the values for the visual. I can't use my measure in the visual because of the error "Cannot Convert value of type text to type true false".

 

Berechneter Frachtumsatz =
CALCULATE (
    [Umsatz ohne GS],
    Prdo5_Sales[Artikel.Artikel Nr] = "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FR_EDI",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FR_AUTO",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FR_AUTO_MD",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FR_AUTO_X",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FR_EDIMAUT",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FRACHTKOST",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FRACHTP",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FR-HARDW",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FR-VBM",
    "FRACHT"
        || Prdo5_Sales[Artikel.Artikel Nr] = "FRACHT"
)
 
This is the whole Measure. 
 
Can someone help me? 
Thanks in advance 🙂 
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

    Please use the below to shorten your code. Also could you check your data type for  [Umsatz ohne GS] is it in text?

     

    Berechneter Frachtumsatz = =
    CALCULATE (
        [Umsatz ohne GS],
        Prdo5_Sales[Artikel.Artikel Nr]
            IN {
            "FRACHT",
            "FR_EDI",
            "FR_AUTO",
            "FR_AUTO_MD",
            "FR_AUTO_X",
            "FR_EDIMAUT",
            "FRACHTKOST",
            "FRACHTP",
            "FR-HARDW",
            "FR-VBM",
            "FRACHT"
        }
    )

     


    BR

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Please use the below to shorten your code. Also could you check your data type for  [Umsatz ohne GS] is it in text?

     

    Berechneter Frachtumsatz = =
    CALCULATE (
        [Umsatz ohne GS],
        Prdo5_Sales[Artikel.Artikel Nr]
            IN {
            "FRACHT",
            "FR_EDI",
            "FR_AUTO",
            "FR_AUTO_MD",
            "FR_AUTO_X",
            "FR_EDIMAUT",
            "FRACHTKOST",
            "FRACHTP",
            "FR-HARDW",
            "FR-VBM",
            "FRACHT"
        }
    )

     


    BR

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      that worked, thanks a lot.

       

      But I still don't understand why it worked. Can you maybe be so kind and explain it a little? 🙂

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        This would be a syntax issue, the word "FRACHT" has been repeated in every filter argument.
        In your case the text operator " || " would still work but would need to revised to follow as per 2nd example below:


        BR