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
Anonymous
Not applicable

Need help on calculated column

Project CodeFlag
1A1
1B1
1C1
2B1
2C1
3D0
3F0
3Q0
4B1
5A0
6C0

 

I want to create a caculated column Flag, If project contains Code B then all records in project will be flgged as 1.  By the way, If the requirment is measure,how to create?

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous Maybe:

 

Column = 
  VAR __Project = [Project]
  VAR __Codes = DISTINCT(SELECTCOLUMNS(FILTER('Table',[Project]=__Project),"Code",[Code]))
RETURN
  IF("B" IN __Codes,1,0)

Measure =
  VAR __Project = MAX([Project])
  VAR __Codes = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table'),[Project]=__Project),"Code",[Code]))
RETURN
  IF("B" IN __Codes,1,0)

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

This calculated column works as well

=if(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[Project]=EARLIER(Data[Project])&&Data[Code]="B"))>0,1,0)

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

@Anonymous Maybe:

 

Column = 
  VAR __Project = [Project]
  VAR __Codes = DISTINCT(SELECTCOLUMNS(FILTER('Table',[Project]=__Project),"Code",[Code]))
RETURN
  IF("B" IN __Codes,1,0)

Measure =
  VAR __Project = MAX([Project])
  VAR __Codes = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table'),[Project]=__Project),"Code",[Code]))
RETURN
  IF("B" IN __Codes,1,0)

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler  Thanks a lot, it worked perfertly

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.