cancel
Showing results for
Did you mean:
Highlighted
Helper I

## Filter data using the value of a filtered table

Hello everyone,

I am using a measure to find the total value of a column based on the value specified.

For example,

`Total = CALCULATE(SUM('Word TimeSeries'[GSC_Combined_Impressions]), FIND("dahlia", 'Word Snapshot'[Word],1,0)>0)`

However, I have 50 product categories for which I want to make the same calculation. So instead of creating 50 measures like the above, is it possible to use a table that will contain all the terms eg dahlia and when that table is filtered using a slicer to use the first value of the column as a value for the FIND formula?

So the measure might look like

`Total = CALCULATE(SUM('Word TimeSeries'[GSC_Combined_Impressions]), FIND([FilteredColumnName], 'Word Snapshot'[Word],1,0)>0)`

Any ideas on how this can be achieved?

Hope the above makes sense.

George

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft

## Re: Filter data using the value of a filtered table

You can add product categories to a slicer, and then pass the selected item value to your FIND function.

Measure =
var selectedvalue = IF(HASONEFILTER('Product'[Product]),LASTNONBLANK('Product'[Product],1),BLANK())
return CALCULATE(SUM(Sales[Sales]),FIND(selectedvalue,Sales[Product],1,0)>0)

Regards,

Charlie Liao

4 REPLIES 4
Highlighted
Resolver V

## Re: Filter data using the value of a filtered table

Use FIRSTNONBLANK Function.

`Total = CALCULATE(SUM('Word TimeSeries'[GSC_Combined_Impressions]), FIND(FIRSTNONBLANK(table[column], ""), 'Word Snapshot'[Word],1,0)>0)`
Highlighted
Helper I

## Re: Filter data using the value of a filtered table

Hello @vik0810

I tried this approach before, but unfortunately, it returns an error. The syntax is not correct because the FIRSTNONBLANK is used in a True/False expression that is used as a table filter expression and it is not allowed.

Regards

George

Highlighted
Microsoft

## Re: Filter data using the value of a filtered table

You can add product categories to a slicer, and then pass the selected item value to your FIND function.

Measure =
var selectedvalue = IF(HASONEFILTER('Product'[Product]),LASTNONBLANK('Product'[Product],1),BLANK())
return CALCULATE(SUM(Sales[Sales]),FIND(selectedvalue,Sales[Product],1,0)>0)

Regards,

Charlie Liao

Highlighted
Helper I

## Re: Filter data using the value of a filtered table

Hello Charlie,

Thank you so much! This is exactly what I needed.

I need to start working more with variables.

Thank you!

Regards
George

Announcements

#### August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

#### Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

#### Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

#### Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors