Forum Discussion
Salauat
5 years agoRegular Visitor
New column calculated by grouping
Hello gents,
I have a table, which contains few columns, which I use to drill through visualizations.
I want to create a new calculated column, which will be looking into "A1" and "Status".
Can you help me to write DAX expression for new column?
Calculated logic as follows:
- If Status is "Good" for all same A1 groups, then the Expected result "Good"
- If at least one row in Status shows "Not Good" in one A1 grouping, then the expected result would be "Not Good"
| A1 | Status | Expected result |
| 1 | Good | Not Good |
| 1 | Not Good | Not Good |
| 1 | Good | Not Good |
| 2 | Good | Good |
| 2 | Good | Good |
| 3 | Not Good | Not Good |
| 3 | Good | Not Good |
| 4 | Not Good | Not Good |
3 Replies
- Jos_Woolley
Solution Sage
Hi,
NewColumn = REPT ( "Not ", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Status] = "Not Good", 'Table'[A1] = EARLIER ( 'Table'[A1] ) ) > 0 ) & "Good"Regards
- Jihwan_Kim
Super User
Expected result CC : =VAR _currentAone = 'Table'[A1]VAR _filtertable =FILTER ( 'Table', 'Table'[A1] = _currentAone )VAR _selectstatuscolumn =SELECTCOLUMNS ( _filtertable, "@status", 'Table'[Status] )RETURNSWITCH (TRUE (),"Not Good" IN _selectstatuscolumn, "Not Good",NOT ( "Not Good" IN _selectstatuscolumn ), "Good") - CNENFRNL
Community Champion
Flag = IF( ISEMPTY( FILTER( INFO, INFO[A1] = EARLIER( INFO[A1] ) && INFO[Status] <> "Good" ) ), "Good", "Not Good" )