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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Filter two tables based on one Page slice and retain it for future calculations

Hi,

I am trying to solve a business problem in PowerBI. I have two data sets that contain forecast details of two different models. The two datasets may have some row items common between them. I have described the two data tables below:

Dataset1:

Forecast Method

Plant

Cost Center

Production Quantity

Spend

Price per unit

Model 1

P1

A

100

250

15

Model 1

P1

B

200

150

19

Model 1

P1

C

300

350

25

Model 1

P2

P

200

150

19

 

Dataset 2:

Forecast Method

Plant

Cost Center

Production Quantity

Spend

Price per unit

Model 2

P1

A

100

250

15

Model 2

P1

B

200

150

19

Model 2

P2

P

200

150

19

 

There is a 1:1 relationship between the two tables using the column โ€œCost Centerโ€.

 

Problem:

I want to create two pages in my dashboard. On first page, I want to give a filter from table to select some cost centers. Based on that selection, I want to filter the data source 1 to exclude the selected cost centers but data source 2 should include the selected cost centers.

 

In the Second page there be a filter of Plant for the users and all the graphs and Calculation should use the combined tables containing both the filtered data set as described earlier and based on the Plant selection the CC selection should still retained as per the subset at that Plant level.

 

Suppose the user selects cost centers: A and P,

then the visuals should work on the table should look like this:

Forecast Method

Plant

Cost Center

Production Quantity

Spend

Price per unit

Model 1

P1

B

200

150

19

Model 1

P1

C

300

350

25

Model 1

P2

Q

300

350

25

Model 1

P2

R

100

250

15

Model 2

P1

A

100

250

15

Model 2

P2

P

200

150

19

 

Please help me if at all, how can it be solved in PowerBI. Also, is it possible to solve it through Powerapps?

 

I am open to connect via skype or Emails for more details and explanations by screen share.

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @Anonymous ,

 

There is one aspect of your setup that I don't understand but maybe is just a visual thing, you want a single table on the first page or two tables?

 

I have create the followin setup:

  • Cost Center table  - to use as slicer
  • Two measures:
Table 1 Filtering =
VAR selected_costcenter =
    ALLSELECTED ( CostCenter[Cost Center] )
RETURN
    IF ( NOT ( MAX ( Table1[Cost Center] ) IN selected_costcenter ); 1; 0 )

Table 2 Filtering =
VAR selected_costcenter =
    ALLSELECTED ( CostCenter[Cost Center] )
RETURN
    IF ( MAX ( Table1[Cost Center] ) IN selected_costcenter; 1; 0 )

 

Now if you use this two measure and filtered them on 1 you should get expected result.

 

See attach PBIX.


Regards

Miguel Fรฉlix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Portuguรชs



View solution in original post

Anonymous
Not applicable

Hi @Anonymous 

As MFelix replied before๏ผŒyou may use a slicer and create measures to achieve your purpose.

On First Page:

Click New table in Modeling Tab:

1.png

 

Filter = VALUES('Table'[Cost Center])

 

Now, you have created a table named Filter which use value(Cost Center) in data source1.

And make a slicer by this table, result as below:

2.png

1.   To filter the data source 1 to exclude the selected cost centers:

Measure1 is as below:

 

Measure1 =

var a = ALLSELECTED('Filter'[Cost Center])

return

CALCULATE(MAX('Table'[Cost Center]),FILTER('Table',NOT('Table'[Cost Center] in a)))

 

 

2.   To filter the data source 2 to include the selected cost centers:

Measure2 is as below:

 

Measure 2 =

var _b = ALLSELECTED('Filter'[Cost Center])

return

CALCULATE(MAX('Table'[Cost Center]),FILTER('Table','Table'[Cost Center] in _b))

 

 

Then we add Measure1 into the table visual made by Data Source1, and add Measure2 into the table visual made by Data Source2.

If we select A and B in Slicer, the result is as below:

3.png

Note1: You can create a measure by click New Measure in Home Tab.

4.png

Note2: You can make multiple choice in Slicer by Ctrl+ left click.

 

On Second Page:

You can make a Slicer like before or use Sync Slicers. More info: https://docs.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-slicers

To get the visual like you show me, we need to combine the table. I have some method:

1.   Use Append in Power Query Editor:

Click Transform data in Home Tab:

1.png

Click Append Queries and select Append Queries as new:

5.png

Select Table (DataSource1) As Primary Table:

2.png

Then we get Result:

3.png2.   Click New Table in Home Tab:

4.png

 

Table 3 = UNION('Table','Table 2')

 

Result:

5.png

Due to the table we built is static and cannot be dynamically selected according to the slicer. Therefore, we still need to create a new measure (Measure3)to display.

 

Measure 3 =

var _c = ALLSELECTED('Filter'[Cost Center])

return

IF(

MAX('Append1'[Forcast Method]) = "Model1",

CALCULATE(MAX('Append1'[Cost Center]),FILTER('Append1',NOT('Append1'[Cost Center] in _c))),

CALCULATE(MAX('Append1'[Cost Center]),FILTER('Append1','Append1'[Cost Center] in _c))

)

 

Then if we select A and P, Result is as below:

6.png

You can download the pbix file form this link:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/tongzhou_qiuyunus_onmicrosoft_com/EQQjgUcWmwlIqRZxezjG16ABQKTs17bazz5bLS9t0SSIhQ?e=wb8rUY

 

Best Regards,

Rico Zhou

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous 

As MFelix replied before๏ผŒyou may use a slicer and create measures to achieve your purpose.

On First Page:

Click New table in Modeling Tab:

1.png

 

Filter = VALUES('Table'[Cost Center])

 

Now, you have created a table named Filter which use value(Cost Center) in data source1.

And make a slicer by this table, result as below:

2.png

1.   To filter the data source 1 to exclude the selected cost centers:

Measure1 is as below:

 

Measure1 =

var a = ALLSELECTED('Filter'[Cost Center])

return

CALCULATE(MAX('Table'[Cost Center]),FILTER('Table',NOT('Table'[Cost Center] in a)))

 

 

2.   To filter the data source 2 to include the selected cost centers:

Measure2 is as below:

 

Measure 2 =

var _b = ALLSELECTED('Filter'[Cost Center])

return

CALCULATE(MAX('Table'[Cost Center]),FILTER('Table','Table'[Cost Center] in _b))

 

 

Then we add Measure1 into the table visual made by Data Source1, and add Measure2 into the table visual made by Data Source2.

If we select A and B in Slicer, the result is as below:

3.png

Note1: You can create a measure by click New Measure in Home Tab.

4.png

Note2: You can make multiple choice in Slicer by Ctrl+ left click.

 

On Second Page:

You can make a Slicer like before or use Sync Slicers. More info: https://docs.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-slicers

To get the visual like you show me, we need to combine the table. I have some method:

1.   Use Append in Power Query Editor:

Click Transform data in Home Tab:

1.png

Click Append Queries and select Append Queries as new:

5.png

Select Table (DataSource1) As Primary Table:

2.png

Then we get Result:

3.png2.   Click New Table in Home Tab:

4.png

 

Table 3 = UNION('Table','Table 2')

 

Result:

5.png

Due to the table we built is static and cannot be dynamically selected according to the slicer. Therefore, we still need to create a new measure (Measure3)to display.

 

Measure 3 =

var _c = ALLSELECTED('Filter'[Cost Center])

return

IF(

MAX('Append1'[Forcast Method]) = "Model1",

CALCULATE(MAX('Append1'[Cost Center]),FILTER('Append1',NOT('Append1'[Cost Center] in _c))),

CALCULATE(MAX('Append1'[Cost Center]),FILTER('Append1','Append1'[Cost Center] in _c))

)

 

Then if we select A and P, Result is as below:

6.png

You can download the pbix file form this link:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/tongzhou_qiuyunus_onmicrosoft_com/EQQjgUcWmwlIqRZxezjG16ABQKTs17bazz5bLS9t0SSIhQ?e=wb8rUY

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

MFelix
Super User
Super User

Hi @Anonymous ,

 

There is one aspect of your setup that I don't understand but maybe is just a visual thing, you want a single table on the first page or two tables?

 

I have create the followin setup:

  • Cost Center table  - to use as slicer
  • Two measures:
Table 1 Filtering =
VAR selected_costcenter =
    ALLSELECTED ( CostCenter[Cost Center] )
RETURN
    IF ( NOT ( MAX ( Table1[Cost Center] ) IN selected_costcenter ); 1; 0 )

Table 2 Filtering =
VAR selected_costcenter =
    ALLSELECTED ( CostCenter[Cost Center] )
RETURN
    IF ( MAX ( Table1[Cost Center] ) IN selected_costcenter; 1; 0 )

 

Now if you use this two measure and filtered them on 1 you should get expected result.

 

See attach PBIX.


Regards

Miguel Fรฉlix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Portuguรชs



Anonymous
Not applicable

@MFelix  @Anonymous  It works!! ๐Ÿ™‚ ๐Ÿ™‚  You both are a genius. Both solutions are very similar and serve the purpose. Replying to the MFelix point, If i want to view the output in a single table? That's right. I would be using the additional steps that Rico has detailed out really well. Again, Thanks a lot folks. Really mean it. Cheers.

Hi @Anonymous ,

 

No genius here just glad to help out.

 

Please mark the correct answer so that other can also get help.


Regards

Miguel Fรฉlix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Portuguรชs



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors