Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |