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
Anonymous
Not applicable

Add 6 months to project start date and sum revenue values within/outside that project

Hi all,

 

I'm trying to add 6 months to a project start date and then sum the values that fell within the project start/end date, as well as summing those which fell outside the dates.

 

PricingProj Date.png

 

I tried to first work out the project end date but I keep getting errors telling me that there are multiple values being supplied... this was my syntax:

 

PricProj Date +6 Mths = IF(ISFILTERED(MD_Sites[Site_Name]),
                            (DATEADD(MD_Sites[Pricing_Project_Date].[Date], +6, MONTH)),
                            "Select a Site")

I have a site table with the name, ID etc of the individual site, as well as it's specific project start date. These could be the same or different for each individual site. There are also a number of sites with no project start date.

 

The project end date should always be 6 months after it started.

 

My attempt at the sum was as follows:

 

Authorised 13D-25 Rev = 
VAR Pricing_Project_Date = CALCULATE(FIRSTDATE(MD_Sites[Pricing_Project_Date]))
VAR Pricing_project_6Mths = CALCULATE(DATEADD(MD_Sites[Pricing_Project_Date], +6, MONTH))
RETURN
CALCULATE(SUMX(REV_Revenue,REV_Revenue[Fee]),
                            FILTER(REV_Revenue,
                            REV_Revenue[TransactionDate] >= Pricing_Project_Date &&
                            REV_Revenue[TransactionDate] <= Pricing_project_6Mths
                            )
)

But I just kept getting blank...

 

Any ideas?

 

Cheers,

Aaron

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

You could add a column to your site table to calculate your +6m, like below.

 

Pricing Project Start Date +6m = DATEADD( Site[Pricing Project Start Date].[Date], 6, MONTH )

 Then you should be able to use the measure below.

Measure = 
CALCULATE(
    SUM( 'Transaction'[Value] ) + 0,
    ISBLANK(Site[Pricing Project Start Date +6m].[Date]) = FALSE(),
    FILTER(
        'Transaction',
        'Transaction'[Transaction Date].[Date] >  RELATED( Site[Pricing Project Start Date +6m].[Date] )
    )
)

Please see my screenshot  below with your desired results.

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

 

View solution in original post

7 REPLIES 7
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

Not sure if I understand your requierment, but have a go at this.


Authorised 13D-25 Rev = 
CALCULATE(
    SUM( REV_Revenue[Fee] ),
    DATEADD( MD_Sites[Pricing_Project_Date].[Date], 6, MONTH )
)
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Anonymous
Not applicable

Hi @Mariusz 

Not quite what I'm looking for but thanks for the reply! You're always very responsive! I actually think I've got a little closer with this measure:

Unauthorised 13D-40 Rev = 
CALCULATE(
    [13D-40 Revenue],
        FILTER(REV_Revenue,
        REV_Revenue[TransactionDate] > (RELATED('MD_Sites'[Pricing_Project_Date])+180)
        )
)

This essentially gets me the correct value I want, but isn't quite as accurate as I'd like it to be. Obviously the assumtion that 180 days is 6 months isn't quite right.

 

I tried to build the DATEADD function into the RELATED function but it doesn't allow it.

 

My logic is slightly different in this example from the original post. This time I'm trying to evaluate the sum of revenue from 6 months after the project start date.

 

Any thoughts?

 

Cheers,

Aaron

Hi @Anonymous 

I thought you should be able to nest RELATED within DATEADD, is it not working for you?

Unauthorised 13D-40 Rev = 
CALCULATE(
    [13D-40 Revenue],
    FILTER(
        REV_Revenue,
        REV_Revenue[TransactionDate] > DATEADD( RELATED('MD_Sites'[Pricing_Project_Date]), 6, MONTH)
    )
)

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski



Anonymous
Not applicable

Hi @Mariusz & @v-piga-msft ,

Perhaps this is easier to explain with some sample dummy data. Take these tables for example:

Region Table

Area IDRegion NameArea Name
1Region 1Area 1
2Region 1Area 2

 

Practice Table

Practice IDPractice Name
1Practice 1
2Practice 2
3Practice 3
4Practice 4

 

Site Table

Site IDSite NameArea IDPractice IDPricing Project Start Date
1Site 11110/11/2018
2Site 21212/12/2018
3Site 32315/09/2018
4Site 424 
5Site 52401/02/2019

 

The Site Table maps to both the region and practice table on their respective "ID" columns. The region is obviously the highest level of the heirarchy.

 

I also have my revenue table:

 

Transaction DateSite IDValue
08/10/2018170
20/10/2018482
07/11/2018546
08/11/2018122
08/11/2018262
03/12/2018445
03/12/2018384
07/12/2018325
17/12/2018196
25/12/2018218
28/12/2018431
04/01/2019212
04/01/2019189
07/01/2019296
28/01/2019276
01/02/2019448
07/02/2019243
18/02/2019456
27/03/2019316
06/04/2019452
26/05/20194100
07/06/2019252
31/07/2019590
01/10/2019243
15/10/2019414
21/10/2019111
13/11/2019380
18/11/2019486
20/11/2019521
04/12/2019187
07/12/2019380

 

I want to be able to calculate the sum of revenue that was gained 6 months after the site pricing project start date. This would mean that each site will have to be calculated individually, as their pricing project start dates are different (or may not even have one). This should then roll up to the practice, area and region level.

 

At the moment, my current formula (below) only evaluates one pricing project date and applies it to all the sites. Therefore, when one site is filtered, the calculation is correct, however when a practice (or higher level in the heirarchy) is selected, the result is wrong.

 

Unauthorised 13D-40 Rev = 
CALCULATE(
    [13D-40 Revenue],
        FILTER(REV_Revenue,
        REV_Revenue[TransactionDate] > (RELATED('MD_Sites'[Pricing_Project_Date])+180)
        )
)

Is there a way to have this calculation evaluate each individual site, then roll it up to the other levels?

For example the aggregated results based on my dummy data should be:

results.png

 

 

 

Cheers,

Aaron

Hi @Anonymous 

You could add a column to your site table to calculate your +6m, like below.

 

Pricing Project Start Date +6m = DATEADD( Site[Pricing Project Start Date].[Date], 6, MONTH )

 Then you should be able to use the measure below.

Measure = 
CALCULATE(
    SUM( 'Transaction'[Value] ) + 0,
    ISBLANK(Site[Pricing Project Start Date +6m].[Date]) = FALSE(),
    FILTER(
        'Transaction',
        'Transaction'[Transaction Date].[Date] >  RELATED( Site[Pricing Project Start Date +6m].[Date] )
    )
)

Please see my screenshot  below with your desired results.

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

 

Anonymous
Not applicable

@Mariusz ,

Apologies for the delay getting back to you - was just testing that this solution works and it does!

 

Thanks very much - I really appreciate it!

 

Aaron

HI @Anonymous 

No problem, always happy to help!

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

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.