Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hi Guys,
I have MTD sales monthly wise. i need to create YTD numbers.
For Ex: Jan-20 = 100, Feb-20 = 150
Jan-20 = 31 days ,Feb-20 =29 days
now, my Feb20 - YTD formula will be ==> (Jan-20*jan-20 days + feb-20*feb-20 days) / (Jan-20days + Feb-20 days)
==> (100*31 + 150*29) / (31+29) = 124.16
Mar20 - YTD formula will be ==>
(Jan-20*jan-20 days + feb-20*feb-20 days+ mar-20*mar-20 days ) / (Jan-20days+Feb-20 days+Mar-20days)
can please help me how we can write dax expression on this requirment.
regards,
som
Solved! Go to Solution.
Hi, @Anonymous
According to your description and sample expressions, I can understand what you want to get, I created some data and achieve the result using DAX, you can take a look and find if it’s useful:
This is my test data:
monthdays =
DATEDIFF(DATE(YEAR([Date]),MONTH([Date]),1),EOMONTH('Table'[Date],0),DAY)+1
Value1 =
[Value]*[monthdays]
Rolling1 =
CALCULATE(SUM([Value1]),FILTER(ALLSELECTED('Table'),[Date]<=EARLIER([Date])))
Rolling2 =
CALCULATE(SUM([monthdays]),FILTER(ALLSELECTED('Table'),[Date]<=EARLIER([Date])))
YTD =
DIVIDE([Rolling1],[Rolling2])
And you can get what you want.
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
According to your description and sample expressions, I can understand what you want to get, I created some data and achieve the result using DAX, you can take a look and find if it’s useful:
This is my test data:
monthdays =
DATEDIFF(DATE(YEAR([Date]),MONTH([Date]),1),EOMONTH('Table'[Date],0),DAY)+1
Value1 =
[Value]*[monthdays]
Rolling1 =
CALCULATE(SUM([Value1]),FILTER(ALLSELECTED('Table'),[Date]<=EARLIER([Date])))
Rolling2 =
CALCULATE(SUM([monthdays]),FILTER(ALLSELECTED('Table'),[Date]<=EARLIER([Date])))
YTD =
DIVIDE([Rolling1],[Rolling2])
And you can get what you want.
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.