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.
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.
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-msft1 year agoCommunity 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.- 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.