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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
anandav
Skilled Sharer
Skilled Sharer

Using a text field in a DAX measure

Hi,

 

While trying to answer a question in this forum I hit a problem.

How can I use a text field in a measure?

e.g.

Dept   Employees

A           2

B           3

 

So how can I do:

Measure := IF('File'[Dept]="A", "This is dept A", "Not dept A")

 

I can do this for a column in a Dax new column or in M via Query Editor.

I understand in a measure there is no row context and need to use an aggregate function (for numeric fields) or calculate function.

 

But cannot figure out how the text field checking can be done in a measure.

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @anandav

 

Give this a try

 

Measure := IF( MAX('File'[Dept])="A", "This is dept A", "Not dept A")

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Phil_Seamark
Employee
Employee

Hi @anandav

 

Give this a try

 

Measure := IF( MAX('File'[Dept])="A", "This is dept A", "Not dept A")

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Worked!

Never thought of using MAX for text field. Smiley Happy

Thanks a lot.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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