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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.