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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
matemusic
Advocate III
Advocate III

Columne as multiple values in filter function (or other ways

Hey everyone.

 

Is there a way, to input column in filter function?

 

Here is an example:

 

var x = values(Here comes a calculated column filter by other measurement condition) 

return
calculate(sum(sales[price]);filter(sales;[product]=x)

So in var x i get list of product names which are filtered by other measure. In return i want to get all products, which are in var x. 

 

Thank you

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @matemusic,

 

As we can define variables with both scalar values and tables, you should be able to define an expression like the following one in your scenario.

[RedSales] :=
VAR RedProducts =
FILTER ( ALL ( Product[Color] ), Product[Color] = "Red" )
RETURN
CALCULATE ( SUM ( Sales[Quantity] ), RedProducts )

In addition, here is a good article about Variables in DAX for your reference.Smiley Happy

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @matemusic,

 

As we can define variables with both scalar values and tables, you should be able to define an expression like the following one in your scenario.

[RedSales] :=
VAR RedProducts =
FILTER ( ALL ( Product[Color] ), Product[Color] = "Red" )
RETURN
CALCULATE ( SUM ( Sales[Quantity] ), RedProducts )

In addition, here is a good article about Variables in DAX for your reference.Smiley Happy

 

Regards

austinsense
Impactful Individual
Impactful Individual

Without ever having done it, I bet you can create a variable that returns a table and then pass that into your measure

 

 

var x = FILTER( VALUES(Products), [Measure])
RETURN
CALCULATE( SUM(Sales[Price]), x)

 

I'm not 100% sure if this is what you're asking for but let me know if it works 🙂

 

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.