Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi Everyone,
I have a table like this:
Item # | Code | Task |
12345 | 7 | ST |
12345 | 8 | CR |
12345 | 9 | RW |
12345 | 10 | CR |
12346 | 3 | ST |
12346 | 4 | CR |
Basically the goal is to end up with another column (Open ST) that will only show open STs. Open STs are determined by NOT having Task RW anywhere after ST.
End goal:
Item # | Code | Task | Open ST |
12345 | 7 | ST | |
12345 | 8 | CR | |
12345 | 9 | RW | |
12345 | 10 | CR | |
12346 | 3 | ST | ST |
12346 | 4 | CR |
So in this case Item # 12346 will end up with ST because there is no Task RW anywhere after Task ST. Item # 12345 won't be an open ST because RW is present somewhere after ST.
As you can see, other Tasks can be present after ST but that's not necessarily relevant as I care about the Tasks ST and RW.
Any thoughts on how I can code this.
Thanks in advance!
Solved! Go to Solution.
Hi,
Try this calculated column formula
Open ST = if(Data[Task]="ST",if(CALCULATE(COUNTROWS(Data),FILTER(data,Data[Item #]=EARLIER(Data[Item #])&&Data[Code]>EARLIER(Data[Code])&&Data[Task]="RW"))>0,BLANK(),Data[Task]),BLANK())
Hope this helps.
@Greg_Deckler thank you. I haven't tried your solution because I found one that works already. I'm confident it will work too. Thanks for taking the time to work on this.
Hi,
Try this calculated column formula
Open ST = if(Data[Task]="ST",if(CALCULATE(COUNTROWS(Data),FILTER(data,Data[Item #]=EARLIER(Data[Item #])&&Data[Code]>EARLIER(Data[Code])&&Data[Task]="RW"))>0,BLANK(),Data[Task]),BLANK())
Hope this helps.
You are welcome.
For fun only, a showcase of powerful Excel worksheet formula,
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@NPC,
Can you see if this fits your criteria?
Open ST =
VAR _GetAllTasks = CALCULATE(CONCATENATEX(NPC, [Task], "|"), FILTER(NPC, NPC[Item #] = EARLIER(NPC[Item #])))
VAR _Exclude = "RW"
VAR _Include = "ST"
RETURN
SWITCH( TRUE(),
SEARCH(_Exclude, _GetAllTasks, 1, 0) > 0, BLANK(),
SEARCH(_Include, _GetAllTasks, 1, 0) > 0 && [Task] = _Include, _Include
)
@hnguy71 thank you. I haven't tried your solution because I found one that works already but all indications are that this would work too. Thanks for taking the time to work on this.
@NPC Try:
Open ST =
VAR __Item = [Item #]
VAR __Code = [Code]
VAR __Table = FILTER('Table',[Code] > __Code && [Item #] = __Item && [Task] = "RW")
RETURN
IF([Task] = "ST" && COUNTROWS(__Table)<1, "ST", BLANK())
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.