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

Total of Monthly/Quarterly/Yearly Revenue calculated wrong

Hi,

 

I have a measure, which calculates the monthly revenue. However, when I add the the data to a table, I get wrong total calculations as can be seen below:

 

WrongQuarterlyRevCalc1.JPG

 

 

Would anyone know what I am doing wrong?

21 REPLIES 21
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try to create another measure based on that.

New measrue = SUMX('Monthly Revenue Table',[Budget per month])

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

@v-frfei-msft 

 

Not sure why, but it still gives the same result as if I had the 'Grand Total' toggled on in the Matrix that I have - 719k

 

 

az38
Community Champion
Community Champion

Hi @Anonymous 

it doesnt look like error, it looks like round question.

pick your Measure at the right pane, go to Modeling ribbon and set desired Decimal places as 2

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 

 

The totals are calculating wrong:

 

Oct rev: 43

Nov rev: 568

Dec rev: 192

 

That is 803, not 599

 

Same goes for 2020 and total of 2019+2020

az38
Community Champion
Community Champion

@Anonymous 

didnt you try CALCULATE over SUMX?

CALCULATE(SUMX(....))

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 

 

I tried, but I it does not seem to work..

 

Total Monthly Revenue = CALCULATE(SUMX('Monthly Revenue Table',[Budget per month]))

 

This calculation still shows the wrong total values

az38
Community Champion
Community Champion

@Anonymous 

no. what kind of values show this measure?

Budget per month = 
CALCULATE(
SUMX (
    ADDCOLUMNS (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)
)

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

@az38 

 

That measure basically calculates the "Monthly Revenue", which can be seen in the above table. So the monthly revenue is correct, but since it has a row context, it calculates the totals wrong. I have found the following two videos, but I am not that good at realising how to implement them into my own measure:

 

https://www.youtube.com/watch?v=44QUjA5NDwY

 

https://www.youtube.com/watch?v=Ka7Ds4EAjNQ

mussaenda
Super User
Super User

you must also show your calculation

Anonymous
Not applicable

Here is the measure of monthly revenue:

 

Budget per month = 
SUMX (
    ADDCOLUMNS (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)

 

 

This is the column calculation:

 

Monthly Revenue = 
IF (
    'Monthly Revenue Table'[Include in financial forecast] = "Yes",
    DIVIDE (
        'Monthly Revenue Table'[Current Client Budget],
        DATEDIFF (
            'Monthly Revenue Table'[Estimated Start Time],
            'Monthly Revenue Table'[Estimated Finish Time],
            MONTH
        ) + 1
    ),
    BLANK ()
)

Both Side of > and < then are there. No <= or >=. Any specific reason.  This can leave the start or end of the month ?

Anonymous
Not applicable

Not sure I follow  @amitchandak ,

 

are you talking about this part of the measure:

 

'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )

 

 

Yes. Both sides do not cover = date, any reason for that?

Anonymous
Not applicable

@amitchandak 

 

I had help writing the measure. It does the job for me, basically calculating the monthly revenue by dividing the "Current Client Budget" by the amount of months that the "Project" spans over.

 

Should I add "=" to those?

Looking at the formula it seems you need that. <= and >= , after that check the number.  If still did not match. Let us know.

Anonymous
Not applicable

@amitchandak,

 

I am afraid it doesn't solve the problem.

 

As I said I believe it might have something to do with the fact the row context has a filter whereas the totals do not as shown in this video:

 

https://www.youtube.com/watch?v=Ka7Ds4EAjNQ

 

I am trying to work my way through, but it is quite difficult for me

Where is the grouping for the month year?   I think you want to group data at month year level and then use that. The is no column added in addcolumns to group by data at month year. Unless I missed it. Add there or try summarize like this

 

Budget per month = 
SUMX (
    summarize (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),<Month>,<Year>,
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)

 

You need two group data on month year. So add one or more column as  group bys

 

 

Anonymous
Not applicable

How exactly am I supposed to use that function you have written.

 

Am I supposed add one column for each month? Like:

 

Budget per month = 
SUMX (
    summarize (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),Month(1),Year(2019),
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)

 

And then for each month?

 

Can you give an example?

Examples

Budget per month = 
SUMX (
    summarize (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),'Monthly Revenue Table'[Month],'Monthly Revenue Table'[Year],
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)

or
Budget per month = 
SUMX (
    summarize (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),'Monthly Revenue Table'[Month-Year],
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)

or

Budget per month = 
SUMX (
    summarize (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),'Date'[Month],'Date'[Year],
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)
Anonymous
Not applicable

@amitchandak 

 

So these are three different options?

If I use this:

 

Budget per month = 
SUMX (
    summarize (
        FILTER (
            'Monthly Revenue Table',
            'Monthly Revenue Table'[Include in financial forecast] = "Yes"
                && NOT (
                    'Monthly Revenue Table'[Estimated Start Time] > MAX ( 'Calendar'[Date] )
                        || 'Monthly Revenue Table'[Estimated Finish Time] < MIN ( 'Calendar'[Date] )
                )
        ),'Monthly Revenue Table'[Month],'Monthly Revenue Table'[Year],
        "AverageBudget", 'Monthly Revenue Table'[Current Client Budget]
            / (
                DATEDIFF (
                    'Monthly Revenue Table'[Estimated Start Time],
                    'Monthly Revenue Table'[Estimated Finish Time],
                    MONTH
                ) + 1
            )
    ),
    [AverageBudget]
)

 

Then I need to add a Month/Year Date to the 'Monthly Revenue Table', however, since projects span over several months (sometimes starting in one year and ending in another) how do I get around that problem then?

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.