Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

How we can create YTD numbers by using MTD

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

 

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

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:

v-robertq-msft_0-1610696267887.png

 

  1. I created these calculated columns:
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])
  1. Then I created a table chart and place like this:

v-robertq-msft_1-1610696267896.png

 

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.

View solution in original post

1 REPLY 1
v-robertq-msft
Community Support
Community Support

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:

v-robertq-msft_0-1610696267887.png

 

  1. I created these calculated columns:
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])
  1. Then I created a table chart and place like this:

v-robertq-msft_1-1610696267896.png

 

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.