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

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

Reply
powerlight1
Frequent Visitor

How to Filter Using a Separate Table

Hi Community,

I am doing some complex calculation and "OR Condition" filtering and need some help.

 

I have a simple table called Baseline with date and sales:

DateBaseline Sales
1/11/202416.8658
2/11/20243.514709
3/11/202495.39742
4/11/202453.36697
5/11/202468.06059
6/11/202466.81327
7/11/202471.91321
8/11/202485.36628
9/11/20241.358787
10/11/202434.57078

 

and I have a second table called Actual sales:

DateActual Sales
1/11/202492.65061
2/11/202487.16787
3/11/202477.94617
4/11/202465.8121
5/11/202454.01474
6/11/202496.31909
7/11/202440.95989
8/11/202415.41474
9/11/202442.09341
10/11/202423.39248
11/11/202429.6792
12/11/202450.02887
13/11/202461.36338
14/11/202448.28854
15/11/202418.21006

 

The relationship between the two tables is just the "Date" column

powerlight1_0-1756092889357.png

In addition I've also created 2 independent date table to use as date slicers :

 

slicer_dates_BL =
SELECTCOLUMNS(
    Baseline
   ,"Date"
    ,[Date])
 
slicer_dates_ACT =
SELECTCOLUMNS(
    Actual
   ,"Date"
    ,[Date])
 
I then created a Measure to use as my filter:
 
Filter_Date =
IF(
    MAX(Baseline[Date]) IN ALLSELECTED(slicer_dates_BL[Date])  
    ,1
    ,0
) 
 

What I then want to show in a table the following:

  1. The average sales from the first 5 days from the Baseline table for period 01.11.2024 to 05.11.2024
  2. The average sales from the Actual table for period 11.11.2024 to 15.11.2024

 

For objective 1. above, I created the 2 Measure:

AVG_Baseline_Sales =
CALCULATE(
    AVERAGE(Baseline[Baseline Sales])
)

 

AVG_Baseline_Sales2 =
CALCULATE(
    AVERAGE(Baseline[Baseline Sales])
    ,FILTER(
        Baseline
        ,MAX([Date]) in ALLSELECTED(slicer_dates_BL[Date])
    )
)
 
 

I then place a table on my canvas placed Filter_Date  in the Filter section of the table and set to equal 1. 

powerlight1_2-1756094120858.png

I then set my baseline date slicer to the period 01.11.2024 to 05.11.2024
powerlight1_1-1756093934823.png

 

I then placed the both measures AVG_Baseline_Sales and AVG_Baseline_Sales2  into the table. 

 

You can see from the screen shot below AVG_Baseline_Sales is calculate the average for the entire 10days and not just the first 5 days, whereas AVG_Baseline_Sales2 is giving me blank.  How do I just show the average of the first 5 days sales without having to place the field "Date" into my results table?

 

powerlight1_3-1756094523631.png

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi  , 

For this I believe you do not need to have two calendar tables.

 

What I modeled was the following:

  • Created a calendar table
    • Needs to start at 1st of January of the minimum year and end at 31 of December of maximum year
    • Be carefull to check the dates between both the sales and the baseline
    • In this case the calendar goes from January 1st 2024 to  31st December 2024
    • Create a one to many between the tables:
      • Calendar - Baseline
      • Calendar - Actual
      • Create the measures below:
        • AVG_Baseline_Sales = CALCULATE( AVERAGE(Baseline[Baseline Sales]), ALL('Calendar'[Date] )) AVG_Baseline_Sales2 = CALCULATE( AVERAGE(Baseline[Baseline Sales]) )Use the calendar table in your slicer
        • Result below

           

          The relationship will pick up the baselines corretly now you can also do a average of the sales and add the date to the visualization:

           

          If you want to keep the average for the 5 days you can create a measure similar to this one:AVG_Baseline_Sales 3 = CALCULATE( AVERAGE(Baseline[Baseline Sales]), ALLSELECTED('Calendar'[Date] )) 

          Please see attach file.

           

            

            

          MFelix_1-1756133569023.png

           

           


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

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Based on the 2 tables that you have shared, show the expected result very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-dineshya
Community Support
Community Support

Hi @powerlight1 ,

Thank you for reaching out to the Microsoft Community Forum.

 

Please follow below steps.

 

1. Created Actual and Baseline tables based on your input data.

 

2. Created disconnected tables  Slicer_dates_BL and Slicer_dates_ACT for slicers.

 

3. Created measures Avg_Baseline_Sales and Avg_Actual_Sales.

 

4. In Table visual, I have dragged measues and in slicers, i have choosed '1/11/2024' to '5/11/2024' in Slicer_dates_BL and '11/11/2024' to '15/11/2025' in Slicer_dates_ACT .

 

Please refer below output snap and attached PBIX file.

 

vdineshya_0-1756212665264.png

 

I hope this information helps. Please do let us know if you have any further queries.

 

Regards,

Dinesh

Hi @powerlight1 ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

Hi @powerlight1 ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

Hi @powerlight1 ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

MFelix
Super User
Super User

Hi  , 

For this I believe you do not need to have two calendar tables.

 

What I modeled was the following:

  • Created a calendar table
    • Needs to start at 1st of January of the minimum year and end at 31 of December of maximum year
    • Be carefull to check the dates between both the sales and the baseline
    • In this case the calendar goes from January 1st 2024 to  31st December 2024
    • Create a one to many between the tables:
      • Calendar - Baseline
      • Calendar - Actual
      • Create the measures below:
        • AVG_Baseline_Sales = CALCULATE( AVERAGE(Baseline[Baseline Sales]), ALL('Calendar'[Date] )) AVG_Baseline_Sales2 = CALCULATE( AVERAGE(Baseline[Baseline Sales]) )Use the calendar table in your slicer
        • Result below

           

          The relationship will pick up the baselines corretly now you can also do a average of the sales and add the date to the visualization:

           

          If you want to keep the average for the 5 days you can create a measure similar to this one:AVG_Baseline_Sales 3 = CALCULATE( AVERAGE(Baseline[Baseline Sales]), ALLSELECTED('Calendar'[Date] )) 

          Please see attach file.

           

            

            

          MFelix_1-1756133569023.png

           

           


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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.