March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
I have a fact table with units and linked to a general time table.
My issue is when using DATESYTD, I want to obtain the following result:
(For this, I used filters on the visual)
For this, I have used the following formula:
UNITS YTD 18=
CALCULATE (
SUM ( 'Actual'[UNITS] ),
SAMEPERIODLASTYEAR ( DATESYTD ( 'Time'[Dates] ) )
)
UNITS YTD 19=
CALCULATE (
SUM ( 'Actual'[UNITS] ),
DATESYTD ( 'Time'[Dates] )
)
The issue is that my data looks like this :
JAN 2018 | 12 |
... | ... |
DEC 2018 | 9 |
JAN 2019 | 3 |
OCT 2019 | 5 |
As you can see, I have months in 2018 that aren't present in 2019. So when I use my measures, DAX keeps calculating data for months when I don't want it to. The output is this:
How can I modify my measures so YTD stops calculating data for months that aren't available in 2019 ?
I posted earlier a solution to this, but actually the formula stopped performing runnings total and gave out monthly total instead.
Thanks !
Solved! Go to Solution.
If you take a slicer and select then it will limit the value of YTD
Or try to limit like
Last YTD Sales =
var _maxMonth = month(maxx(Sales,Sales[sales_date]))
CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year)), month(Date[date])<=_maxMonth)
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
If you take a slicer and select then it will limit the value of YTD
Or try to limit like
Last YTD Sales =
var _maxMonth = month(maxx(Sales,Sales[sales_date]))
CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year)), month(Date[date])<=_maxMonth)
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
@amitchandak Thank you so much.
I've tried so many variations of this, the solution was to use MAXX and not simply MAX !
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
126 | |
77 | |
59 | |
56 | |
42 |
User | Count |
---|---|
184 | |
106 | |
84 | |
59 | |
48 |