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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

How to pass a column into filter() ?

I'm trying to calculate the last year sales dynamically based off of the dates selected on the slicer. Within my date dimension table, each calendar date has a corresponding last year date. I've created a measure to do that:

 

pbi_Net_Sales_Total_LY_old = CALCULATE(sum(Merch[net_amt]), filter(all('Merch'), Merch[trans_dt] = VALUES('Calendar'[CALENDAR_DT_LY])))


This works fine if only one value has been selected, as shown below.

 

single value.jpg

 

When more than one value has been selected, it throws a multiple value error message.

 

multiple values.jpg

 
My approach is capturing the last year dates that are based off of the dates selected on the slicer and passing them into the filter in my measure so that it will only sum the sales that has a transaction date that equals to the last year dates that I'm passing. Seems like "Merch[trans_dt] =" doesn't like mulitple values and VALUES('Calendar'[CALENDAR_DT_LY]) containing multiple values is not helping. Is there anyway I can make the filter accept multiple values, in my case a column that contains multiple values? Or, is my approach the correct way of doing this?

Here's an extremely simiplified version of what my data model looks like:

 

data model.jpg

 

 

If this matters, the data model is actually in Analysis Services, not in Power Bi.

 

3 REPLIES 3
AlB
Community Champion
Community Champion

Hi @Anonymous

 

I think the  easiest way would be to have a relationship between Calendar[CALENDAR_DT_LY] and [trans_dt]. By doing that the slicer would filter Merch directly. Is that possible? 

If you already have another active relationship between those two tables you can always creative an additional inactive one and activate it within the measure through USERELATIONSHIP.

 

 

Anonymous
Not applicable

That wouldn't be possible because the entire dashboard revolves around looking at specific time period using [trans_dt], which is a many to one relationship to calendar[calendar_dt]. Also, end users will not be using last year dates as a selection criteria. The whole point of this measure is to calculate last year's sales dynamically without any user interaction.

Just need to figure out how to make the filter accept multiple values that are dynamic. Unless my approach is not the correct way of going about doing what I want.....

P.S. This would be so much easier in SQL.....
Anonymous
Not applicable

Bumping this back up because my last edit removed all my images and formating. Also realized that it did not include enough context to make things clear, added more information to my original post.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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