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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
manhuynguyen
Frequent Visitor

Filter hundred of values

Dear Power BI users,

 

I have a filtering issues that needs your support:

The data I have looks like this:

ItemCategory
AX1; X3; X5
BX3; X5; X7
CX4; X8; X9
DX5; X8
EX11; X12
FX9; X5

 

Now I would like to see those Items that have "X3 or X5 or X7". In this case, item C & E will NOT appear.

What would be the way to do this effectively? Given that my actual data has hundred of categories need to be filtered.

 

Thanks a lot,

1 ACCEPTED SOLUTION

@manhuynguyen 

Hi 

I gave you a DAX code. You can not use it in power query side.
Please try following M code in power query.

if Text.Contains([Category] , "X3") or Text.Contains([Category] , "X5") or Text.Contains([Category] , "X7") then "True" else "False"

 Thank you.

View solution in original post

6 REPLIES 6
Dinesh_Suranga
Continued Contributor
Continued Contributor

@manhuynguyen 

Did you change table name and column name according to your data table?

Thanks

1.PNGHi @Dinesh_Suranga, yes I did. Would you help me to see what could be wrong with my queries as above? Thanks

@manhuynguyen 

Hi 

I gave you a DAX code. You can not use it in power query side.
Please try following M code in power query.

if Text.Contains([Category] , "X3") or Text.Contains([Category] , "X5") or Text.Contains([Category] , "X7") then "True" else "False"

 Thank you.

Sorry my bad, but when I tried it in DAX, it's still not return desirable outcome

manhuynguyen_1-1668435808543.png

So thank you very much, I'll accept this as a solution.

But when I tried in Power Query, it works perfectly.

manhuynguyen_2-1668435949234.png

 

Dinesh_Suranga
Continued Contributor
Continued Contributor

@manhuynguyen 

Hi,

Please try following DAX code.

Measure = CONTAINSSTRING( SELECTEDVALUE('Table'[Category]),"X3") || CONTAINSSTRING( SELECTEDVALUE('Table'[Category]),"X5") || CONTAINSSTRING( SELECTEDVALUE('Table'[Category]),"X7") 

Dinesh_Suranga_0-1668164842574.png

Then you can filter True values.

If this helps you to solve your issue. Please accept this as the solution.

Thank you.

 

Hi, 

 

I tried it but it showed error: "Token eof expected"

Could you send me your pbix file as an example for this?

 

I'd really appreciate it.

Best regards,

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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