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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Akshay123
Frequent Visitor

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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