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

Measure for revenue decreasing over time

 Hi,

 

I am having trouble with presenting decreasing amount of incoming revenue over time.

Here is input dummy data that illustrates my data:

ProjectRevenueStartEndMarginMonthsMonthly RevenueMonthly MarginType
abc100001.1.201831.12.2018100012833.3383.33Old
xxx150001.2.201831.5.2019250016937.50156.25New
xyz280001.6.201831.12.20195500191473.68289.47New

 

The aim is to show how the remaining revenue decreases over time.  I.e. for project "abc" the starting point would be 10 000 and each month 833 would be deducted. The end month would then give a value of 833 (it could also be done to show 10 000 - 833 in the first month and 0 in the last month).

Like this (done in excel):

Project       Month   Revenue left  Margin left

abc 01 201810000.001000.00
abc 02 20189166.67916.67
abc 03 20188333.33833.33
abc 04 20187500.00750.00
abc 05 20186666.67666.67
abc 06 20185833.33583.33
abc 07 20185000.00500.00
abc 08 20184166.67416.67
abc 09 20183333.33333.33
abc 10 20182500.00250.00
abc 11 20181666.67166.67
abc 12 2018833.3383.33

 

Here's what I'm looking for in the graph:

revenue.PNG

 

 

 

 

 

 

 

 

 

 

 

 

I've tried expanding the input table months for each project and then deducting cumulative revenue from the original revenue. It works when I handle the projects separately, but as soon as I aggregate the data, the measure does something weird.

 

Here's the Dax I use:

Revenue Accumulation = CALCULATE(
SUM('Project Table Expanded'[Monthly Revenue]);
DATESBETWEEN(
'Project Table Expanded'[MonthYear];
MINX(ALL('Project Table Expanded'[MonthYear]);'Project Table Expanded'[MonthYear]);MAX('Project Table Expanded'[MonthYear])))
Revenue left = SUM('Project Table Expanded'[Revenue])+SUM('Project Table Expanded'[Monthly Revenue]) - 'Project Table Expanded'[Revenue Accumulation]

 

The weird stuff happpens after the second project ends (months in Finnish, but in correct order - sorry about that): wierd.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

EDIT: here's the current relationships I'm working with
relationships.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Here is a pbix and excel describing in more detail: dummyData

 

 

Br,

T

 

1 ACCEPTED SOLUTION
AkhilAshok
Solution Sage
Solution Sage

There are multiple ways to do this. One option is without using Project Expanded table (bigger DAX measures, formula engine driven, can get slow bigger dataset) and another is using Project Expanded table (simpler DAX, storage engine driven, fast for bigger dataset).

 

Since your dataset is pretty small, it doesn't matter which approach you use. But, I will explain the option using Project Expanded since that is what you already tried. Below is the approach I followed - started with your Project Table.

 

1. Create a Month table like below and sort the Year Month column using Year Month Number

 

Month =
GROUPBY (
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Project Table'[Start] ), MAX ( 'Project Table'[End] ) ),
        "Year Month", FORMAT ( [Date], "mmm yy" ),
        "Year Month Number", YEAR ( [Date] ) * 12
            + MONTH ( [Date] )
            - 1
    ),
    [Year Month],
    [Year Month Number],
    "Month Start", MINX ( CURRENTGROUP (), [Date] )
)

 

2. Create a new table Project Table Expanded (since you said you created yours in Excel - just to show we can do everything in Power BI itself Smiley Happy)

 

Project Table Expanded = 
GENERATE (
    'Project Table',
    DATESBETWEEN ( 'Month'[Month Start], 'Project Table'[Start], 'Project Table'[End] )
)

3. Create a Relatioship between Project Table Expanded & Month using Month Start column.

 

 

4. Create the following Measures:

 

Total Revenue = SUM('Project Table Expanded'[Revenue])

Monthly Revenue RT =
CALCULATE (
    SUM ( 'Project Table Expanded'[Monthly Revenue] ),
    FILTER ( ALL ( 'Month' ), 'Month'[Month Start] < MAX ( 'Month'[Month Start] ) )
)

Revenue Left =
SUMX (
    VALUES ( 'Project Table Expanded'[Project] ),
    [Total Revenue] - [Monthly Revenue RT]
)

5. Create your Chart using the Month[Year Month], 'Project Table Expanded'[Type] and [Revenue Left]

 

image.png

 

Let me know if it works for you.

View solution in original post

2 REPLIES 2
AkhilAshok
Solution Sage
Solution Sage

There are multiple ways to do this. One option is without using Project Expanded table (bigger DAX measures, formula engine driven, can get slow bigger dataset) and another is using Project Expanded table (simpler DAX, storage engine driven, fast for bigger dataset).

 

Since your dataset is pretty small, it doesn't matter which approach you use. But, I will explain the option using Project Expanded since that is what you already tried. Below is the approach I followed - started with your Project Table.

 

1. Create a Month table like below and sort the Year Month column using Year Month Number

 

Month =
GROUPBY (
    ADDCOLUMNS (
        CALENDAR ( MIN ( 'Project Table'[Start] ), MAX ( 'Project Table'[End] ) ),
        "Year Month", FORMAT ( [Date], "mmm yy" ),
        "Year Month Number", YEAR ( [Date] ) * 12
            + MONTH ( [Date] )
            - 1
    ),
    [Year Month],
    [Year Month Number],
    "Month Start", MINX ( CURRENTGROUP (), [Date] )
)

 

2. Create a new table Project Table Expanded (since you said you created yours in Excel - just to show we can do everything in Power BI itself Smiley Happy)

 

Project Table Expanded = 
GENERATE (
    'Project Table',
    DATESBETWEEN ( 'Month'[Month Start], 'Project Table'[Start], 'Project Table'[End] )
)

3. Create a Relatioship between Project Table Expanded & Month using Month Start column.

 

 

4. Create the following Measures:

 

Total Revenue = SUM('Project Table Expanded'[Revenue])

Monthly Revenue RT =
CALCULATE (
    SUM ( 'Project Table Expanded'[Monthly Revenue] ),
    FILTER ( ALL ( 'Month' ), 'Month'[Month Start] < MAX ( 'Month'[Month Start] ) )
)

Revenue Left =
SUMX (
    VALUES ( 'Project Table Expanded'[Project] ),
    [Total Revenue] - [Monthly Revenue RT]
)

5. Create your Chart using the Month[Year Month], 'Project Table Expanded'[Type] and [Revenue Left]

 

image.png

 

Let me know if it works for you.

Anonymous
Not applicable

Thank you @AkhilAshok!

 

I'll give this a go and tell you how it works.

Thanks for using the Project Expanded - the real dataset has 500 projects instead of 3.

 

Br,

T

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.