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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Akshay123
Helper I
Helper I

Need to Show last 7 days data on Total YTD calculation

Hello Experts,

 

I have used below logic to find Total YTD values. When I used it in a visual I see no's for entire year. I just want to show the last 7 days of the values in the graph.

When I use relative day option under filter pane, It filters data for last 7 days and calculates and gives the result.

 

TotalYTDMeasure = TOTALYTD([Total New Open], Cal[Date].[Date])
 
Akshay123_0-1715792277539.png

 

2 REPLIES 2
v-nuoc-msft
Community Support
Community Support

Hi @Akshay123 

 

If you are not getting the total calculated data for the last seven days correctly, it may have something to do with the function you are using.

 

TOTALYTD is intended to represent an expression calculated for the current year-to-date date.

 

Therefore, the function will start counting from the beginning of the current year, regardless of the filter criteria you have in the filter pane.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“Table”

vnuocmsft_2-1715824836513.png

 

Here I recommend you to modify the code as follows, create a measure:

 

Measure = 
var _lastdate = MAX('Table'[year])
var _startdate = _lastdate - 7
RETURN
CALCULATE(
    SUM('Table'[values]), 
    FILTER(
        ALL('Table'), 
        'Table'[year] >= _startdate && 'Table'[year] <= _lastdate
    )
)

 

Here is the result.

 

vnuocmsft_1-1715824774731.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

HI @v-nuoc-msft 

When I am using date column within the table, above solution it works, 

In my report I used a calander table to show the dates, for blank dates it's not showing the values

for blanks it has to show the previous values

 

Akshay123_0-1715850203124.png

 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.