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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Employee
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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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