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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vmadm
Regular Visitor

search values in a column with conditions from other columns

Hi everyone,

I am starting to use power BI and I have a difficulty.

I have a table similar to this

 

code 1code 2state
1AOpen
2BReviewed
3CReviewed
4DReviewed
5EReviewed
6BClosed
7BOpen
8AReviewed
9CReviewed
10AOpen
11FClosed

 

I need to get the values of code1 or the corresponding rows in which the following conditions are met:
- the state is reviewed
- There is no other row with the same code 2 where the status is different from revised

For the table above, the result should be

 

code 1code 2state
3CReviewed
4DReviewed
5EReviewed
9CReviewed

 

Or

 

Codes 1:  3,4,5,9

 

 

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hi. I don't really get what you need to do but I think this might help. This can be solved with power query too, but you asked in dax forum so I will do it on dax.

You can add a calculated column to flag your codes2 that have a state different from "Reviewed" to let you know about this condition. Like this:

FlagColumn = 
IF (
    Tabla[code 2] IN ( 
        SELECTCOLUMNS(
            FILTER( Tabla; Tabla[state] <> "Reviewed" )
            ; "codi"; Tabla[code 2] 
        )
    );
    TRUE();
    FALSE()
)

With this flag you can just filter the table as you wish:

 

dax column falg to filterdax column falg to filter

This is not the better solution regarding performance, but I don't know what you will do with this.

Hope this helps,

 

Regards,


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

Happy to help!

LaDataWeb Blog

View solution in original post

2 REPLIES 2
ibarrau
Super User
Super User

Hi. I don't really get what you need to do but I think this might help. This can be solved with power query too, but you asked in dax forum so I will do it on dax.

You can add a calculated column to flag your codes2 that have a state different from "Reviewed" to let you know about this condition. Like this:

FlagColumn = 
IF (
    Tabla[code 2] IN ( 
        SELECTCOLUMNS(
            FILTER( Tabla; Tabla[state] <> "Reviewed" )
            ; "codi"; Tabla[code 2] 
        )
    );
    TRUE();
    FALSE()
)

With this flag you can just filter the table as you wish:

 

dax column falg to filterdax column falg to filter

This is not the better solution regarding performance, but I don't know what you will do with this.

Hope this helps,

 

Regards,


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

Happy to help!

LaDataWeb Blog

Thanks,

 

This solved my problem,

 

Regards.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors