The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi, I have a table of the form:
id case status 0 1 xx 0 555 yy 0 125 zz 2 87 yy 2 nn xx
And I am trying to code something like the below:
for every id if 1 case has status xx and 1 case has status yy, THEN I want yy = xx
So the resulting table would be
id case status 0 1 xx 0 555 **xx** 0 125 zz 2 87 **xx** 2 nn xx
I tried with
Column= IF ( MAXX ( FILTER ( 'Table', 'Table'[id] = EARLIER ( 'Table'[id] ) && 'Table'[status] = "xx" ), 'Table'[status] ) = "", "", "xx" )
but that doesn't work as it would transform all the *statuses* per *id* into -xx-.
Any help on this?
Thanks
Solved! Go to Solution.
You can create a calculated column like
Actual Status = IF( 'Table'[status] = "yy",
VAR NumXX = CALCULATE(
COUNTROWS( 'Table' ),
ALLEXCEPT( 'Table', 'Table'[id]),
'Table'[status] = "xx"
)
VAR NumYY = CALCULATE(
COUNTROWS( 'Table' ),
ALLEXCEPT( 'Table', 'Table'[id] ),
'Table'[status] = "yy"
)
VAR Result = IF( NumXX = 1 && NumYY = 1, "xx", 'Table'[status] )
RETURN Result,
'Table'[status]
)
You can create a calculated column like
Actual Status = IF( 'Table'[status] = "yy",
VAR NumXX = CALCULATE(
COUNTROWS( 'Table' ),
ALLEXCEPT( 'Table', 'Table'[id]),
'Table'[status] = "xx"
)
VAR NumYY = CALCULATE(
COUNTROWS( 'Table' ),
ALLEXCEPT( 'Table', 'Table'[id] ),
'Table'[status] = "yy"
)
VAR Result = IF( NumXX = 1 && NumYY = 1, "xx", 'Table'[status] )
RETURN Result,
'Table'[status]
)
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
5 |
User | Count |
---|---|
25 | |
13 | |
12 | |
8 | |
8 |