Forum Discussion
TotalYTD returning blank
I have searched extensively about this issue and have yet to see the same type of issue resolved.
I must be able to utilize a filter to return the YTD value up until a certain year/week timeframe.
I must calculated the YTD value for each TR Type - AOG, Crtitical, Standard.
Since there are no AOG TR Types handled in the week of Latest (aka week 2025 - 13) the result is returning blank (or zero because I added a +0)
As you can se in my visual the result should be 13. If I change my filter to 2025 - 12, I see the result of 13 for AOG. However, it always shows 0 on a year/week in which no AOG TR Types were handled.
Does anyone have any thoughts on this how to get it to show 13?
Hi kinga,
Thanks for your patience and the detailed updates!
I now fully understand the issue, the main challenge is that when the selected Year Week (like 2025-13) has no records for a TR Type (e.g., AOG), the YTD measure returns 0, even though there were values in earlier weeks (like 13 in 2025-12).
I’ve rewritten the DAX to better handle this. It now:
- Finds the last non-blank week for each TR Type up to the selected week.
- Returns the full YTD total up to that last available week, even if the current week has no data.
Please try this revised measure:
YTD Shipments = VAR SelectedYearWeek = MAX ( 'Table'[YearWeek] ) VAR LastNonBlankWeek = CALCULATE ( MAX ( 'Table'[YearWeek] ), FILTER ( ALL ( 'Table' ), 'Table'[YearWeek] <= SelectedYearWeek && 'Table'[Shipments] > 0 && 'Table'[TR_Type] = SELECTEDVALUE ( 'Table'[TR_Type] ) ) ) RETURN CALCULATE ( SUM ( 'Table'[Shipments] ), FILTER ( ALL ( 'Table' ), 'Table'[YearWeek] <= LastNonBlankWeek && 'Table'[TR_Type] = SELECTEDVALUE ( 'Table'[TR_Type] ) ) ) + 0This should now return 13 for AOG even when 2025-13 has no entries.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
10 Replies
- lbendlinSuper User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - v-kpoloju-msftCommunity Support
Hi kinga,
Thank you for reaching out to the Microsoft fabric community forum. Thank you lbendlin, for your inputs on this issue. After thoroughly reviewing the details you provided, I was able to reproduce the scenario, and it worked on my end. I have used it as sample data on my end and successfully implemented it.
Please try this measure I have tried with some sample data in my end, it worked fine:
YTD Shipments =VAR SelectedWeek = MAX( 'Table'[YearWeek] )
VAR LastAvailableWeek =
CALCULATE(
MAX( 'Table'[YearWeek] ),
'Table'[YearWeek] <= SelectedWeek,
ALLEXCEPT( 'Table', 'Table'[TR_Type] )
)
RETURN
CALCULATE(
SUM( 'Table'[Shipments] ),
'Table'[YearWeek] <= LastAvailableWeek
)
I am also including .pbix file in the below for your better understanding, please have a look into it:
I hope this could resolve your issue, if you need any further assistance, feel free to reach out. If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.- kingaHelper I
Thanks so much for your quick response! I tried to incorporate with no success. I opened the PBIX sample file and see that there is an entry for TR Type AOG on week 2025 - 13, which in my case there is no entries for this week. I think this is where my problem stems from.
- v-kpoloju-msftCommunity Support
Hi kinga,
I apologize for any inconvenience caused. After reviewing the details you provided, I have outlined the following steps. Please follow the steps below:Please ensure that there are no active filters (such as slicers, page filters, or report-level filters) that could be hiding AOG entries. Verify that all TR Types are included in the table visual, as some filters might be excluding AOG.
Open the data view in Power BI and manually search for TR Type AOG to confirm its existence for week 2025-13. If there is no AOG data for week 2025-13 in their dataset, the measure should return the last available value (e.g., 13) instead of 0.Please try this modified DAX measure: (Table name should be “Table”)
YTD Shipments =VAR SelectedWeek = MAX( 'Table'[YearWeek] )
VAR LastAvailableWeek =
CALCULATE(
MAX( 'Table'[YearWeek] ),
'Table'[YearWeek] <= SelectedWeek,
'Table'[Shipments] > 0, -- Ensure only weeks with shipments are considered
ALLEXCEPT( 'Table', 'Table'[TR_Type] )
)
RETURN
CALCULATE(
SUM( 'Table'[Shipments] ),
'Table'[YearWeek] <= LastAvailableWeek,
'Table'[TR_Type] = SELECTEDVALUE('Table'[TR_Type]) -- Keep TR Type context
) + 0 -- Ensure it does not return blank
If possible, please copy and paste the data table they are working with to confirm if AOG is missing.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.