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
danb
Resolver I
Resolver I

DAX - Crossjoin with Criteria

I have been asking Copilot but without success so coming to the real experts! 

I have two tables, one called 'BrandForecast' and the other 'Running Calendar'. I am trying to figure out how to do a crossjoin in dax with a catch. I don't want each campaign to be repeated for all of the weeks in the Running Calendar. Instead i only want the crossjoin to take place when the [Week Starting (Monday Start) is greater than or equal to the [Promotion Start Date] and less than or equal to the [Promotion End Date]. I have included working data below:

The end result I am trying to get to is something like this: 

Week Starting (Monday Start)CampaignPromotion Start DatePromotion End DatePlateBaselineForecast
11/3/2025Monthly 311/3/202511/30/2025Ramen2711
11/3/2025Monthly 311/3/202511/30/2025Soba3012
11/3/2025Monthly 311/3/202511/30/2025Shrimp Faces2944
11/10/2025Monthly 311/3/202511/30/2025Ramen2711
11/10/2025Monthly 311/3/202511/30/2025Soba3012
11/10/2025Monthly 311/3/202511/30/2025Shrimp Faces2944
11/17/2025Monthly 311/3/202511/30/2025Ramen2711
11/17/2025Monthly 311/3/202511/30/2025Soba3012
11/17/2025Monthly 311/3/202511/30/2025Shrimp Faces2944
11/24/2025Monthly 311/3/202511/30/2025Ramen2711
11/24/2025Monthly 311/3/202511/30/2025Soba3012
11/24/2025Monthly 311/3/202511/30/2025Shrimp Faces2944



'BrandForecast'

CampaignPromotion Start DatePromotion End DatePlateBaselineForecast
Core 112/30/20246/29/2025Burger w/Avocado1015
Core 112/30/20246/29/2025Steak & Eggs611
Core 112/30/20246/29/2025Mayo Sandwich39
Core 26/30/202511/30/2025Sausage Pizza514
Core 26/30/202511/30/2025Stinky Cheese Plate35
Core 26/30/202511/30/2025Bacon Burger515
Monthly 110/3/202510/30/2025Fish Sandwich289
Monthly 110/3/202510/30/2025Shrimp Plate4116
Monthly 110/3/202510/30/2025Nacho Fries2927
Monthly 26/30/20257/27/2025Carne Asada3831
Monthly 26/30/20257/27/2025Pork Carnitas749
Monthly 26/30/20257/27/2025Tacos4730
Monthly 311/3/202511/30/2025Ramen2711
Monthly 311/3/202511/30/2025Soba3012
Monthly 311/3/202511/30/2025Shrimp Faces2944
Promo6/2/20256/29/2025Ice Cream1422
Promo6/2/20256/29/2025Melted Butter1630
Promo6/2/20256/29/2025Lettuce & Raisens4823


'Running Calendar'

Week Starting (Monday Start)
11/4/2024
11/11/2024
11/18/2024
11/25/2024
12/2/2024
12/9/2024
12/16/2024
12/23/2024
12/30/2024
1/6/2025
1/13/2025
1/20/2025
1/27/2025
2/3/2025
2/10/2025
2/17/2025
2/24/2025
3/3/2025
3/10/2025
3/17/2025
3/24/2025
3/31/2025
4/7/2025
4/14/2025
4/21/2025
4/28/2025
5/5/2025
5/12/2025
5/19/2025
5/26/2025
6/2/2025
6/9/2025
6/16/2025
6/23/2025
6/30/2025
7/7/2025
7/14/2025
7/21/2025
7/28/2025
8/4/2025
8/11/2025
8/18/2025
8/25/2025
9/1/2025
9/8/2025
9/15/2025
9/22/2025
9/29/2025
10/6/2025
10/13/2025
10/20/2025
10/27/2025
11/3/2025
11/10/2025
11/17/2025
11/24/2025
12/1/2025
12/8/2025
12/15/2025
12/22/2025
12/29/2025
1/5/2026
1/12/2026
1/19/2026
1/26/2026
2/2/2026
2/9/2026
2/16/2026
2/23/2026
3/2/2026
3/9/2026
3/16/2026
3/23/2026
1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@danb 

create a calculatedtable as below : 

filter ( 

crossjoin ( table1 , table2 ) , 

 [Week Starting (Monday Start) >= [Promotion Start Date]  && [Week Starting (Monday Start)  <= [Promotion End Date]

)

 

hope this helps . 

View solution in original post

7 REPLIES 7
danextian
Super User
Super User

Try this:

CrossJoinedTable = 
GENERATE (
    BrandForecast,
    VAR StartDate = BrandForecast[Promotion Start Date]
    VAR EndDate = BrandForecast[Promotion End Date]
    RETURN
        SELECTCOLUMNS (
            FILTER (
                RunningCalendar,
                RunningCalendar[Week Starting (Monday Start)] >= StartDate &&
                RunningCalendar[Week Starting (Monday Start)] <= EndDate
            ),
            "Week Starting (Monday Start)", RunningCalendar[Week Starting (Monday Start)]
        )
)

danextian_0-1744456803919.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I haven't messed around with GENERATE, what are the benefits of that function from a performance perspective versus crossjoin? 

Go ahead and compare the performance.  You would have to look at the query plan to see if there is even a difference.

lbendlin
Super User
Super User

There is no magic to it.

 

Result = FILTER(CROSSJOIN(BrandForecast,'Running Calendar'),[Week Starting] IN CALENDAR([Promotion Start Date],[Promotion End Date]))

 

No idea if there is any performance benefit using GENERATE instead. Probably not.

 

Result2 = GENERATE(BrandForecast,filter('Running Calendar',[Week Starting] in CALENDAR([Promotion Start Date],[Promotion End Date])))

Thanks - I haven't played with GENERATE before but will check that out. 

Daniel29195
Super User
Super User

@danb 

create a calculatedtable as below : 

filter ( 

crossjoin ( table1 , table2 ) , 

 [Week Starting (Monday Start) >= [Promotion Start Date]  && [Week Starting (Monday Start)  <= [Promotion End Date]

)

 

hope this helps . 

Appreciate it! I was trying =calculatetable(crossjoin(... and it wasn't working. Simpler is better! 

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.