Forum Discussion
TotalYTD returning blank
- 1 year ago
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.
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.
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.
- v-kpoloju-msft1 year agoCommunity Support
Hi kinga,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
- v-kpoloju-msft1 year agoCommunity Support
Hi kinga,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.- v-kpoloju-msft1 year agoCommunity Support
Hi kinga,
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.