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
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.
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”
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.
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
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
112 | |
112 | |
105 | |
94 | |
58 |
User | Count |
---|---|
174 | |
147 | |
136 | |
102 | |
82 |