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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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