Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Kevykev
Regular Visitor

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 To Appear) in the Court Hearing Result column between a specified date starting and ending date range.  

 

IN addidtion, I then need to make another meausre off of that expressing the percentages of FTA results based on the Total COUNT of hearings in that data range.

 

Can someone help me with these DAX formulas?

 

Thank you!

4 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@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] 

View solution in original post

Tahreem24
Super User
Super User

@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.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

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!

View solution in original post

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!

View solution in original post

4 REPLIES 4
Tahreem24
Super User
Super User

@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.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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!

Anonymous
Not applicable

@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] 

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!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.