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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
antoniopgouveia
Frequent Visitor

Crossjoin table from start to finish date by ID

Hi all,

 

I'm trying to build a table with DAX with the crossjoin function but I need it to follow certain conditions. I have a table with information about several different opportunities, which have information about the amount, stage, probability, close date, etc. This table records all of these information everytime an update is made to that opportunity and it looks like the table below (for simplification I'm only including amount values):

 

OpportunityIDCreatedDateCurrentDateAmount
006D000000yMreEIAS19/01/201828/08/2018120000
006D000000yMreEIAS27/06/201828/08/2018200000
006D000000yMreEIAS04/08/201828/08/2018600000
006D000000yMreEIAS05/08/201828/08/2018800000

 

What I want to do is for each opportunity (given by the OpportunityID) I want to create rows that display the value of the opportunity in each month since its creation until the current date. If there are multiple amount alterations in the same month, I would like to get the last value for that month. In this example, it would be like this (notice that this sample contains only data for a single opportunity and it tracks the several updates there was to the opportunity) :

 

OpportunityIDCreatedDateCurrentDateAmount
006D000000yMreEIAS19/01/201828/08/2018120000
006D000000yMreEIAS28/02/201828/08/2018120000
006D000000yMreEIAS31/03/201828/08/2018120000
006D000000yMreEIAS30/04/201828/08/2018120000
006D000000yMreEIAS31/05/201828/08/2018120000
006D000000yMreEIAS27/06/201828/08/2018200000
006D000000yMreEIAS31/07/201828/08/2018200000
006D000000yMreEIAS05/08/201828/08/2018800000

 

I have done a cross join between my Opportunity table and my Calendar table with the following conditions:

 

CrossJoin = FILTER(CROSSJOIN('Opportunity', 'Calendar'), 'Calendar'[Date] >= 'Opportunity'[CreatedDate] && 'Calendar'[Date] <= 'Opportunity '[CurrentDate])

But this is creating entries for each row from created to current date and not by OpportunityID, as I want. I would need a formula that would recognize the next created date within the same opportunity and would add rows until that date. Plus, I don't mind it having creating rows for all days in the month, I can just select the latest one later on. It is only important to know what the value was for each month since the creation until the end/current date of the opportunity. Any ideas?

 

Best regards,

Antonio

1 ACCEPTED SOLUTION
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @antoniopgouveia,

Based on my test, you could try to use this formula:

CrossJoin= CROSSJOIN('Opportunity', CALCULATETABLE('Calendar',FILTER('Calendar','Calendar'[Date] >= MIN('Opportunity'[CreatedDate]) && 'Calendar'[Date] <= MIN('Opportunity'[CurrentDate]))))

 

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

2 REPLIES 2
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @antoniopgouveia,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

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.
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @antoniopgouveia,

Based on my test, you could try to use this formula:

CrossJoin= CROSSJOIN('Opportunity', CALCULATETABLE('Calendar',FILTER('Calendar','Calendar'[Date] >= MIN('Opportunity'[CreatedDate]) && 'Calendar'[Date] <= MIN('Opportunity'[CurrentDate]))))

 

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.