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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
BSLATTER
Helper III
Helper III

Use a slicer to filter an unrelated table using a mock CONTAINSX calculation

Hello,

 

I am attempting to allow users to select a value (Fiscal Period) and that will drive many other visual calculations. They will select this Period in a slicer.

 

In some calculations the period will be a max value, whereas others it will be the only value. So for that reason I cannot have them pick all the periods they want to look at. IE:
If they pick Period 2, it would show Sales in Period2, but show Inventory from Period 1 and 2 (Where Period < MAX(SelectedPeriod))

 

The issue is they COULD pick multiple periods. IE:
User picks Period 2 and Period 4, it would shows sales in P2 and P4, but show Inventory from P1-P4 (< MAX selected)

 

To accomplish this, I have a created table with no joins to any other table in the data and just has the periods that we are allowing users to select from. This works except for the situations where it would show only the specific Periods they select. I cannot get the calculations to compare a single value against a table of multiple values.


I did find this article CONTAINSX which gave me this calculation:

PeriodExists = IF(
COUNTROWS(
FILTER('FiscalPeriodDateAggDim (2)',
SEARCH('FiscalPeriodDateAggDim (2)'[PeriodFilterKey],
FiscalPeriodDateAggDim[PeriodFilterKey], 1, 0)
)
),
1,
0
)
 
This does 95% of what I want of providing the join between the two tables (Both FiscalPeriodDateAgg and FiscalPeriodDateAgg2) - except it's ignoring when I filter on the value [PeriodNum] in the slicer, and not filtering those out of FiscalPeriodDateAgg2 in order to effect the first table.
 
Sample data:
FiscalDateAggPeriod
 
YearPeriodPeriodOffsetPeriodNamePeriodFilterKeyPeriod Exists
201810-5Period 1010BLANKPeriod 10BLANK0
201811-4Period 1111BLANKPeriod 11BLANK0
201812-3Period 1212BLANKPeriod 12BLANK0
20191-2Period 11BLANKPeriod 1BLANK1
20192-1Period 22BLANKPeriod 2BLANK1
201930Period 31BLANKPeriod 1BLANK0
 
FiscalDateAggPeriod2
YearPeriodPeriodOffsetPeriodNamePeriodFilterKey
20191-2Period 11BLANKPeriod 1BLANK
20192-1Period 22BLANKPeriod 2BLANK
 
 
Goal: Have a slicer on "PeriodNumber" in FiscalDateAggPeriod2 and have the above calculation (PeriodExists) be affected by that filter. IE: Select Period 1 only and have Period 2 value in PeriodExists change to 0
 
1 ACCEPTED SOLUTION
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @BSLATTER ,

Based on my test, you could refer yo below formula:

Measure = IF(CALCULATE(SUM(FiscalDateAggPeriod[Period]))<=CALCULATE(MAX('FiscalDateAggPeriod2'[Period]),FILTER('FiscalDateAggPeriod2','FiscalDateAggPeriod2'[PeriodName]=SELECTEDVALUE(FiscalDateAggPeriod2[PeriodName]))),1,0)

Result:

1.PNG2.PNG

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @BSLATTER ,

Based on my test, you could refer yo below formula:

Measure = IF(CALCULATE(SUM(FiscalDateAggPeriod[Period]))<=CALCULATE(MAX('FiscalDateAggPeriod2'[Period]),FILTER('FiscalDateAggPeriod2','FiscalDateAggPeriod2'[PeriodName]=SELECTEDVALUE(FiscalDateAggPeriod2[PeriodName]))),1,0)

Result:

1.PNG2.PNG

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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