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
jimmymitra
Advocate I
Advocate I

Pass Filter context of measure into the calculated column in DAX

Hi Friends , 

 

My apology if the question has been asked in the forum already , I tried to search , but could not find one. 

 

Here is my question - 

I have a measure M1 that calcuates number of distinct "Currency Code" based on the filters selected in the slicers. 

 

Based on the measure I am creating a calculated column called "FinalCurrency" 

 

The requirement is if the value of M1 is 3 , then the calculated column "FinalCurrency" will have "Euro" ,else "Other"

 

But my problem is two fold - 

1. In calculated column , if I use the measure M1 ,it does not carry the filter context selected by the user , instead it considers the entire table data , how do I pass the filter context of the measure M1 in the calculated column

2. Is there a way I can create a non-numeric measure , e.g. Measure M2 to have value "Euro" if M1 = 3

In that case I will not have to create a calculated column

 

Hope I could able to make myself clear in my question

Thanks in advance for your kind reply

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @jimmymitra

 

Answering your questions:

  1. No - calculated columns are computed at refresh, so cannot take into account slicer selections or filters of any kind.
  2. Yes you can create a measure returning a text string, such as
    M2 =
    IF ( [M1] = 3, "Euro", "Other" )
    This measure will work in general, but there is a possibility you would have to wrap the expression in CALCULATE(..., ALLSELECTED() ) to ensure it returns the same value in all filter contexts within a particular report page (sounds like that's the behaviour you need).

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

1 REPLY 1
OwenAuger
Super User
Super User

Hi @jimmymitra

 

Answering your questions:

  1. No - calculated columns are computed at refresh, so cannot take into account slicer selections or filters of any kind.
  2. Yes you can create a measure returning a text string, such as
    M2 =
    IF ( [M1] = 3, "Euro", "Other" )
    This measure will work in general, but there is a possibility you would have to wrap the expression in CALCULATE(..., ALLSELECTED() ) to ensure it returns the same value in all filter contexts within a particular report page (sounds like that's the behaviour you need).

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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.