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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
JEFriedrichs
Regular Visitor

FILTER function with a List as filter condition

Hello everyone!

 

I have a customer who does a lot of different filterings, i.e. for Article groups and subgroups, location groups and subgroups, including changing overlap and changing groups. To have one measure to sum them up, I thought I would work with a variable list in the filters, like this:

msrQuantity =

VAR
    ItemList = "12345, 54321"

RETURN
    CALCULATE(
        SUM(InventoryData[QTY]),
        FILTER(
        InventoryData,
        InventoryData[ItemNumber] IN {ItemList}
        )
    )

 

Ultimately, the ItemList would be a CONCATENATEX-Function, and there will be additional conditions added.

 

The function only returns data if the list is a single value (i.e. were it only "12345", I get the right item. I also tried putting them further into brackets like "{12345}, {54321}", but that doesn't change the table, either.

 

Is this possible, or are there better ways to achieve this?

1 ACCEPTED SOLUTION

@JEFriedrichs 

Simply

 

VAR ItemList = VALUES(dimProduct[ItemNumber)

 

View solution in original post

6 REPLIES 6
JEFriedrichs
Regular Visitor

Just a second after I post this question I see I formatted the list wrong, each value needs to be in quotation marks, and not the whole string, like {"12345", "54321"}. The filter condition works that way, too. But then the question is how can I build such a list string i.e. using CONCATENATEX?

tamerj1
Super User
Super User

Hi @JEFriedrichs 
lease use

msrQuantity =
VAR ItemList = { "12345", "54321" }
RETURN
    CALCULATE (
        SUM ( InventoryData[QTY] ),
        FILTER ( InventoryData, InventoryData[ItemNumber] IN ItemList )
    )

Thank you! I'm feeling really stupid right now, I saw that a minute after I made this post. Do you have any idea how I would automatically generate such a ItemList-String variably, though? I.e. using a CONCATENATEX?

@JEFriedrichs 
Generate it out of what? What is the input? Also CNCATENATEX won't help you, you need a table not a scallar concatenated string value

Thank you so much for your help. Keeping it simple, it would be a dimProduct table that is filtered many different ways in i.a. a table visual with filter visuals next to it, so my initial thought would be replacing the List string with

 

VAR ItemList = CONCATENATEX(dimProduct, dimProduct[ItemNumber], ",")

 

But as you say, I don't get the right thing out of this. CONCATENATEX isn't the right function. How do I get there, though?

@JEFriedrichs 

Simply

 

VAR ItemList = VALUES(dimProduct[ItemNumber)

 

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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