Forum Discussion

Kevykev's avatar
Kevykev
Regular Visitor
6 years ago
Solved

Create a Measure based on string value

Hello! I'm starting to learn DAX but running into issues where I need to create measures based on STRING values.  For example: I need to count the number of occurances of the string "FTA" (Failure ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Kevykev Create a calculated column: 

     

    HasFTA := IF (Find("FTA",[Court Hearing Result],1,-1) = -1, 0, 1)

     

    Create a new measure as FTACount = SUM([HasFTA]) in the same table where you created a new column "HasFTA"

     

    Then a TotalRecords = CALCULATE(COUNTROWS(TABLE),ALL)

     

    Percentages would be FTA% = [FTACount]/[TotalRecords] 

  • Tahreem24's avatar
    6 years ago

    Kevykev ,

     

    YOu can create a measure based on string condition using FILTER DAX. Please follow the below DAX meausre to get your output:

    Measure = CALCULATE(COUNT('Table'[Court Hearing Result]),FILTER(ALL('Table'),'Table'[Court Hearing Result]="FTA"),DATESBETWEEN('Table'[DateColumn],FIRSTDATE('Table'[DateColumn]),LASTDATE('Table'[DateColumn])))
     
    Don't forget to give thumbs up 👍 and accept this as a solution if it helped you.
  • Kevykev's avatar
    Kevykev
    6 years ago

    Thank you very much.  This helps me greatly be getting an example that I can now see applied to my data model and business use case!

  • Kevykev's avatar
    Kevykev
    6 years ago

    Thank you very much.  This helps me greatly be getting an example that I can now see applied to my data model and business use case!