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
bdurham15
Frequent Visitor

Line Chart displays wrong dates with TTM measure

Hello,

 

I have a standard line chart with a trendline that displays almost all of my measures, except for any "TTM" Measures that I have. Non date bound measures work ok, as well as measures that I am using TOTALMTD((QTD),(YTD)) with. Even though I have a consecutive series of months selected in a slicer above, when using the TTM measures, all months in the calendar are displayed.  I have been using the chart in published reports for weeks now, but recently updated my calendar table to run completely in query editor, so that I have to make little to no changes in calculated columns. When comparing to my old dataset, I can't seem to find what may be different or what is causing this problem. Also note that in this same report page I have the measures working properly in a table.
image.png

image.png

 

image.png

TTM Total Sales = 
CALCULATE (
    [Total Sales],
    DATESBETWEEN (
        'Calendar'[Date],
        NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( 'Calendar'[Date] ) ) ),
        LASTDATE ( 'Calendar'[Date] )
    )
)

 

1 ACCEPTED SOLUTION

After doing some more digging Mr. Ferrari at SQLBI was able to help out. Adding this bolded and italicized portion to the forumla did away with the unwanted dates, and is also the most efficient way to make the calculation (compared to an IF statement that would excluded the dates not selected).

@v-yulgu-msft thank you for your help regardless!

TTM Total Sales = 
DIVIDE( [Total Sales], [Total Sales] ) * 
CALCULATE (
    [Total Sales],
    DATESBETWEEN (
        'Calendar'[Date],
        NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( 'Calendar'[Date] ) ) ),
        LASTDATE ( 'Calendar'[Date] )
    )
)

 

 

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @bdurham15,

 

Please set the X-axis type to Categorical for a test.

1.PNG

 

regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yulgu-msft, thank you for your response, unfortunately this does not correct the issue.

image.png

After doing some more digging Mr. Ferrari at SQLBI was able to help out. Adding this bolded and italicized portion to the forumla did away with the unwanted dates, and is also the most efficient way to make the calculation (compared to an IF statement that would excluded the dates not selected).

@v-yulgu-msft thank you for your help regardless!

TTM Total Sales = 
DIVIDE( [Total Sales], [Total Sales] ) * 
CALCULATE (
    [Total Sales],
    DATESBETWEEN (
        'Calendar'[Date],
        NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( 'Calendar'[Date] ) ) ),
        LASTDATE ( 'Calendar'[Date] )
    )
)

 

 

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.