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!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello! I'm having trouble doing something that seems simple.
My table follows this structure:
| ID | STATUS | LAST_STEP |
| 111 | Not approved | TRUE |
| 111 | Approved | TRUE |
| 222 | Approved | TRUE |
| 222 | Approved | TRUE |
| 222 | Not approved | FALSE |
| 333 | Approved | FALSE |
| 333 | FALSE | |
| 333 | Approved | TRUE |
| 333 | Approved | TRUE |
| 444 | Approved | TRUE |
| 444 | TRUE |
I want to create a calculated column that checks, for each ID, if the number of rows where STATUS="Approved" and the number of rows where LAST_STEP=TRUE are the same. If they are the same, then this new column would show "OK" (if not it shows "NOK").
The expected result would be something like this:
| ID | STATUS | LAST_STEP | NEW_COLUMN |
| 111 | Not approved | TRUE | NOK |
| 111 | Approved | TRUE | NOK |
| 222 | Approved | TRUE | OK |
| 222 | Approved | TRUE | OK |
| 222 | Not approved | FALSE | OK |
| 333 | Approved | FALSE | OK |
| 333 | FALSE | OK | |
| 333 | Approved | TRUE | OK |
| 333 | Approved | TRUE | OK |
| 444 | Approved | TRUE | NOK |
| 444 | TRUE | NOK |
Solved! Go to Solution.
@nok,
Try this calculated column:
New Column =
VAR vID = 'Table'[ID]
VAR vStatusApproved =
COUNTROWS ( FILTER ( 'Table', 'Table'[ID] = vID && 'Table'[STATUS] = "Approved" ) )
VAR vLastStepTrue =
COUNTROWS ( FILTER ( 'Table', 'Table'[ID] = vID && 'Table'[LAST_STEP] = TRUE ) )
VAR vResult =
IF ( vStatusApproved = vLastStepTrue, "OK", "NOK" )
RETURN
vResult
Check your expected result for ID 333. It has three Approved rows and two True rows, hence NOK.
Proud to be a Super User!
For your reference.
I add a 'New_Column' column below.
New_Column = IF(CALCULATE(COUNTX(FILTER('DATA','DATA'[STATUS]="Approved"),'DATA'[STATUS]),ALLEXCEPT('DATA','DATA'[ID]))=CALCULATE(COUNTX(FILTER('DATA','DATA'[LAST_STEP]="true"),'DATA'[LAST_STEP]),ALLEXCEPT('DATA','DATA'[ID])),"OK","NOK")
Just incase if you want it in form of a table
Table = ADDCOLUMNS (
SUMMARIZE (
Step,
Step[LAST_STEP],
Step[ID],
Step[STATUS]
),
"New_Column",
VAR ApprovedCount =
CALCULATE (
COUNTROWS ( Step ),
ALLEXCEPT(Step,Step[ID]),
Step[STATUS] = "Approved"
)
VAR StatusCount =
CALCULATE (
COUNTROWS ( Step ),
ALLEXCEPT(Step,Step[ID]),
Step[LAST_STEP] = "TRUE"
)
RETURN IF (ApprovedCount=StatusCount, "OK","NOK")
)
I never knew its possible to use variables in combination with Summarize. Learned something new.
For your reference.
I add a 'New_Column' column below.
New_Column = IF(CALCULATE(COUNTX(FILTER('DATA','DATA'[STATUS]="Approved"),'DATA'[STATUS]),ALLEXCEPT('DATA','DATA'[ID]))=CALCULATE(COUNTX(FILTER('DATA','DATA'[LAST_STEP]="true"),'DATA'[LAST_STEP]),ALLEXCEPT('DATA','DATA'[ID])),"OK","NOK")
@nok,
Try this calculated column:
New Column =
VAR vID = 'Table'[ID]
VAR vStatusApproved =
COUNTROWS ( FILTER ( 'Table', 'Table'[ID] = vID && 'Table'[STATUS] = "Approved" ) )
VAR vLastStepTrue =
COUNTROWS ( FILTER ( 'Table', 'Table'[ID] = vID && 'Table'[LAST_STEP] = TRUE ) )
VAR vResult =
IF ( vStatusApproved = vLastStepTrue, "OK", "NOK" )
RETURN
vResult
Check your expected result for ID 333. It has three Approved rows and two True rows, hence NOK.
Proud to be a Super User!
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 64 | |
| 53 | |
| 42 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 124 | |
| 105 | |
| 44 | |
| 32 | |
| 24 |