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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
anwessel
Regular Visitor

New Column for Matching Column 2 to Column 1

Column 1 (Project ID) contains repeating values.

Column 2 contains a series of values, maximum of 1 of each per project ID (column 1). 

 

I want to add a new column that adds value of "Canceled" whenever column 2 contains "Canceled", but to mark that for all rows where Project ID matches.

 

Example from screenshot below:

Project ID: 64f1de08076108cf4638f61b4def8bdb 
Print Statuses: Sent to print, Not submitted, Printing, Shipped, Canceled

 

Since this Project ID has Print Status of "canceled", I want to mark all rows with 64f1de08076108cf4638f61b4def8bdb as "Canceled" in a new column. 

 

Alternatively,

Project ID: 64f9d23a01d07f63c698ec40de8e9f51 does NOT have the print status of "canceled", so the new column would be blank for all rows of this Project ID. 

 

anwessel_0-1709924277657.png

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @anwessel ,

 

Thank you @HotChilli  for the quick response and solution. Here are some of my additions:
According to your first description, you can create such a calculated column:

Column 1 = 
var _a=COUNTAX(FILTER('Table','Table'[project id]=EARLIER('Table'[project id]) && 'Table'[print status]="canceled"),[project id])
RETURN IF(_a>0,"canceled",[print status])

Based on your second description, you can create a calculated column like this:

Column 2 = 
 var _a=COUNTAX(FILTER('Table','Table'[project id]=EARLIER('Table'[project id]) && 'Table'[print status]="canceled"),[project id])
RETURN IF(_a=BLANK(),BLANK(),[print status])

Then the result is as follows.

vtangjiemsft_0-1710138605292.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

4 REPLIES 4
v-tangjie-msft
Community Support
Community Support

Hi @anwessel ,

 

Thank you @HotChilli  for the quick response and solution. Here are some of my additions:
According to your first description, you can create such a calculated column:

Column 1 = 
var _a=COUNTAX(FILTER('Table','Table'[project id]=EARLIER('Table'[project id]) && 'Table'[print status]="canceled"),[project id])
RETURN IF(_a>0,"canceled",[print status])

Based on your second description, you can create a calculated column like this:

Column 2 = 
 var _a=COUNTAX(FILTER('Table','Table'[project id]=EARLIER('Table'[project id]) && 'Table'[print status]="canceled"),[project id])
RETURN IF(_a=BLANK(),BLANK(),[print status])

Then the result is as follows.

vtangjiemsft_0-1710138605292.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Thank you, @v-tangjie-msft! Your column 1 calculation works great! This will get me where I need to go. 

HotChilli
Super User
Super User

Create a calculated column.

Count the rows which have the same projectID as the current row with Print Status = "Canceled"

, for example,

var _Pid = theTable[Project ID]
var _CanceledRow = COUNTROWS(FILTER(theTable, theTable[Project ID] = _Pid && theTable[Print Status] = "Canceled"))

this should put 0 or 1 in _CanceledRow.

Write an IF statement that tests the value of _CanceledRow.  If greater than 0 then "Canceled"

lbendlin
Super User
Super User

Please provide sample data in usable format (not as a screenshot).

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors