Forum Discussion

tijuemson's avatar
tijuemson
Frequent Visitor
5 years ago
Solved

return Yes or no from column

Download data here 

 

So i am in a pickle

i have to find certain customers from a survey results if they fill anything like sucidal or self harm and i need to flag it.

 

so i used containsstring to find out if those words are there or not

 

Now i need a code to return "True" if any row value in that column contains "true" 

 

if all the row values in the column is false then "false"

 

can anybody help 

 

adding data here

 

  • Hi tijuemson 

    This Measure will work, but you haven't provided actual data to test against.

     

    Measure = MAX('Table'[Column1])

     

    Doing a MAX on a text column will return "True" if it exists anywhere, otherwise you will get "False".  T comes after F in the alphabet.  This is assuming the column can only contain "True"or "False" as you described.

    Regards

    Phil

11 Replies

    • amitchandak's avatar
      amitchandak
      Icon for Super User rankSuper User

      tijuemson , for that you need a new column like , this will have same status for a id, say survey id

      if(isblank(maxx(filter(Table,[survey id] = earlier([survey id]) && [Flag] = true()),[survey id])), false(), true())

  • nvprasad's avatar
    nvprasad
    Icon for Solution Sage rankSolution Sage

    Hi,

     

    Please try with the below dax funtion.

     

    Check =
    IF (
    OR (
    CONTAINSSTRING ( Survey[Response], "sucidal" ),
    CONTAINSSTRING ( Survey[Response], "self harm" )
    )
    = TRUE (),
    "True",
    "False"
    )
     

    Appreciate a Kudos! 🙂
    If this helps and resolves the issue, please mark it as a Solution! 🙂

    Regards,
    N V Durga Prasad

    • tijuemson's avatar
      tijuemson
      Frequent Visitor

      Hi Prasad,

       

      I have done this part.

      but now i want to add this to the report.

       

      but since i am doing columnwise it only shows the first or last value

       

      but i want to return True even if atleast one true is there

       

      and if all are no then no

       

      thanks

  • Hi tijuemson 

    This Measure will work, but you haven't provided actual data to test against.

     

    Measure = MAX('Table'[Column1])

     

    Doing a MAX on a text column will return "True" if it exists anywhere, otherwise you will get "False".  T comes after F in the alphabet.  This is assuming the column can only contain "True"or "False" as you described.

    Regards

    Phil

    • tijuemson's avatar
      tijuemson
      Frequent Visitor

      data is added thanks

       

      i cant unpivot it because the data is in a funny way

      • PhilipTreacy's avatar
        PhilipTreacy
        Icon for Super User rankSuper User

        Thx tijuemson 

        So that's the Excel file but you saisd you already brough the data into PBI and wrote some DAX to create a column containing either True or False ?

        Have you tried the Measure I provided?

        regards

        Phil