Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Dear all,
I have a report where I track my orders. I created a calendar table based on my dates in my data and marked it as a date table.
Normally I can calculate YTD as a measure but due to new year's delivery dates my calendar includes dates for 2021 and my formula stop working. Do I miss something or do I have to update my measure?
regards
my data table and calendar table relation is based on "Delivery Date"
Date = VAR MinYear = Year (MIN('Fullfilment Report'[Created On]))
VAR MaxYear = Year (MAX('Fullfilment Report'[Delivery date]))
RETURN
ADDCOLUMNS( FILTER ( CALENDARAUTO() , AND ( YEAR( [Date]) >= MinYear , YEAR ([Date]) <= MaxYear)) ,
"Year" , YEAR([Date]),
"Month", MONTH([Date]),
"Month Name" , FORMAT([Date], "MMM"),
"Week Nr" , WEEKNUM([Date],2),
"Year Month" , FORMAT([Date], "YYYY.MM") )
my YTD measure
YTD =
CALCULATE ( [New Fulfillment Rate2], DATESYTD ( 'Date'[Date] ) )
Solved! Go to Solution.
What context and visuals are you using this in?
You can either
OPTION A: update your formula to use manual reference to TODAY(), such as:
YTD =
CALCULATE ( [New Fulfillment Rate2], YEAR(FactTable[Date]) = YEAR(TODAY()))
or, OPTION B: add a year context to your report by putting a date filter on the page that has 2020 as the max year.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi, @jamuka
It’s my pleasure to answer for you.
According to your description, It's not vey clear where problems occur, but you can try to do it without time intelligence function.
Like this:
YTD =
VAR d =
MAX ( 'Date'[Date] )
RETURN
CALCULATE (
[New Fulfillment Rate2],
FILTER (
ALL ( 'Fullfilment Report' ),
YEAR ( [Delivery Date] ) = YEAR ( d )
&& [Delivery Date] <= d
)
)
If it doesn’t solve your problem, please add more information and feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello Janey,
sorry for late reply. thanks to Allison I solved my problem.
My calendar table has date entries for 2021 (due to delivery dates) and I calculated YTD based on delivery date therefore my YTD measure returns blank values. I add year filter to my measure (which will show current year) and it works.
With your fomula it shows same value for every entry in my matrix table.
regards
What context and visuals are you using this in?
You can either
OPTION A: update your formula to use manual reference to TODAY(), such as:
YTD =
CALCULATE ( [New Fulfillment Rate2], YEAR(FactTable[Date]) = YEAR(TODAY()))
or, OPTION B: add a year context to your report by putting a date filter on the page that has 2020 as the max year.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hello Allison,
sorry for late reply. thank you for your help. both of your options worked.
have nice week.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
109 | |
98 | |
39 | |
30 |