cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bdeluca
Frequent Visitor

Show results before and after a chosen date (when referencing two date tables)

Long-time prowler. First time posting. Here’s my dilemma:

 

I have two datasets, each organized by date. The data tables DO NOT have the same start/end date. I would like to choose a date (x in this example). Based on x, I want to sum() dataset 1 until the day prior to x. And sum() dataset 2 from x forward.

 

I have found several solutions that get me close, but because the two datasets are different fact tables (with non-matching dates), I am stumped when it comes to developing a summary table/matrix that encompass both datasets.

bdeluca_0-1616084795293.png

 

3 REPLIES 3
lbendlin
Super User
Super User

Create a calendar table that can act as a dimension table to your two fact tables, and that can feed your slicer.

I believe I tried what you are suggesting. I followed this tutorial:

 

https://www.youtube.com/watch?v=zYIxukD2KCM

 

The issue, though, is non-matching date tables. For context, I'm creating an Accounts Receivable report. It pulls in all past data until this date selected. Then - pulling from another fact table - pulls the remaining data.

 

I can accomplish this if I use two matrices and manually manipulate the date filter. However, my goal is to have this in one matrix with one slicer (and a date variable, I suppose) so that the report looks more orderly.

ERD
Resident Rockstar
Resident Rockstar

Hello @bdeluca ,

From what I've got from your explanation is that you need 2 measures and a slicer.

Indeed, you need to create a dimention table to be used in your slicer that will contain all the dates from both tables. You can create it either in Power Query or DAX based on either provided start/end date or on min/max dates of youe existing fact tables. 

Measures that might be used:

#Dataset_1 = 
VAR selectedDate = SELECTEDVALUE(Calendar[Date])
RETURN 
    SUMX(
        FILTER(ALL(Dataset1), Dataset1[Date] < selectedDate),
        Dataset1[Dataset1]
    )

#Dataset_2 = 
VAR selectedDate = SELECTEDVALUE(Calendar[Date])
RETURN 
    SUMX(
        FILTER(ALL(Dataset2), Dataset2[Date] >= selectedDate),
        Dataset2[Dataset2]
    )

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors
Top Kudoed Authors