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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MAkiva1
Helper I
Helper I

Trailing Twelve Month Revenue

I am seeing a very large discrepancy between the desktop version of Power BI and the online for this field.  I'm not too sure what's causing the discrepancy and I'm looking for help.  Specifics below:

 

I calculate revenue using three separate fields in a SQL database. I've computed the TTM revenue as follows:

 

TTM Revenue = CALCULATE(SUM(CUST_ContactTable2_121703[Fee Amount]),DATESINPERIOD(CUST_ContactTable1_085310[INSettDate],TODAY(),-365,DAY),CUST_ContactTable1_085310[INUIMSettDate]=BLANK()) + CALCULATE(SUM(CUST_ContactTable2_121703[Fee Amount]),DATESINPERIOD(CUST_ContactTable1_085310[INUIMSettDate],TODAY(),-365,DAY)) + CALCULATE(DIVIDE((SUM(CUST_ContactTable1_085310[CUST_INSettAmnt_111008586]) + SUM(CUST_ContactTable1_085310[CUST_INUIMSettAmnt_111324801])),3),CUST_ContactTable2_121703[Fee Amount]=BLANK(),DATESINPERIOD(CUST_ContactTable1_085310[INSettDate],TODAY(),-365,DAY))

 

In the desktop version of Power Bi, this computes accurately.  In the online portal, the number is 1/6 of the desktop result.  Any suggestions as to why?  I'm using DirectQuery and I refreshed the data.  Gateway is working fine, as other fields are updated accurately.

3 REPLIES 3
Reid_Havens
Most Valuable Professional
Most Valuable Professional

Hi there,

 

Glad to offer some help. First off, if you're unfamiliar with DAX Formatter. Great tool to clean up large DAX formulas. I used it to section out your formula to better read it. First question for you, is there a reason you're doing -365 DAYS instead of -1 YEAR?

=
CALCULATE (
    SUM ( CUST_ContactTable2_121703[Fee Amount] ),
    DATESINPERIOD ( CUST_ContactTable1_085310[INSettDate], TODAY (), -365, DAY ),
    CUST_ContactTable1_085310[INUIMSettDate] = BLANK ()
)
    + CALCULATE (
        SUM ( CUST_ContactTable2_121703[Fee Amount] ),
        DATESINPERIOD ( CUST_ContactTable1_085310[INUIMSettDate], TODAY (), -365, DAY )
    )
    + CALCULATE (
        DIVIDE (
            (
                SUM ( CUST_ContactTable1_085310[CUST_INSettAmnt_111008586] )
                    + SUM ( CUST_ContactTable1_085310[CUST_INUIMSettAmnt_111324801] )
            ),
            3
        ),
        CUST_ContactTable2_121703[Fee Amount] = BLANK (),
        DATESINPERIOD ( CUST_ContactTable1_085310[INSettDate], TODAY (), -365, DAY )
    )

 

No reason.

Reid_Havens
Most Valuable Professional
Most Valuable Professional

I personally use Alberto Ferrari's method of creating a 12-month window for a value. The full article can be found here. But I'll include the formula below. I'd recommend maybe seeing if this works in the Desktop app first, and then on PBI.com.

 

Sales12M := CALCULATE (
    [Sales],
    DATESBETWEEN (
        Calendar[FullDate],
        NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( Calendar[FullDate] ) ) ),
        LASTDATE ( Calendar[FullDate] )
    )
)

Quote from his article:

 

"

The behavior of the formula is simple: it computes the value of [Sales] after creating a filter on the calendar that shows exactly one full year of data. The core of the formula is the DATESBETWEEN, which returns an inclusive set of dates between the two boundaries. The lower one is:

 
SAMEPERIODLASTYEAR ( NEXTDAY ( LASTDATE ( Calendar[FullDate] ) ) ) 
 

Reading it from the innermost: if we are showing data for a month, say July 2007, we take the last visible date using LASTDATE, which returns the last day in July 2007. Then we use NEXTDAY to take the 1st of August 2007 and we finally use SAMEPERIODLASTYEAR to shift it back one year, yielding 1st of August 2006. The upper boundary is simply LASTDATE, i.e. end of July 2007.

"

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.