cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
anandav Established Member
Established Member

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

Accepted Solutions
Super User
Super User

Re: Using a text field in a DAX measure

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!

2 REPLIES 2
Super User
Super User

Re: Using a text field in a DAX measure

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!

anandav Established Member
Established Member

Re: Using a text field in a DAX measure

Worked!

Never thought of using MAX for text field. Smiley Happy

Thanks a lot.