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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
srivally
Helper I
Helper I

Calculate YTD for duplicate dates

Hello Experts,

I am very new to PowerBI. I searched a lot to calculate YTD and came to know that we can calculate YTD only when we have distinct continous dates. But in my case I have multiple values for single date and I wanted to calculate YTD. I tried the following calculation
YTD = TOTALYTD(SUM('Sales'[Net Sales]),'Date'[Date]), but I'm getting same values as NetSales. It is not calculating YTD as we are having multiple values for single date. Here Sales is the main table and Date is Calendar table, I have created 1:1 relationship among Sales and Date table by  creating unique column and tried. But no luck as we are having multiple dates in Date table as well. Can anyone help me on this?

 

Thanks

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@srivally,

You date table doesn't contain all the possible date values of your sales table, and you don't create relationship between the two tables, thus you don't get expected YTD value.

Please check the attached PBIX file.


Regards,
Lydia

Community Support Team _ Lydia Zhang
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

14 REPLIES 14
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@srivally,

You date table doesn't contain all the possible date values of your sales table, and you don't create relationship between the two tables, thus you don't get expected YTD value.

Please check the attached PBIX file.


Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft
I have created the relationship, but I'm getting YTD as blank values. I have attached the same here
https://www.dropbox.com/h

@srivally

Please check your Date table and create a visual as shown in the YTD-MOD PBIX file. By the way, I am unable to access your PBIX file.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft
I have checked the Date table and Sales table as well. I'm not sure where I'm missing. Can you please help me on this.
https://www.dropbox.com/s/nrjusedc2na7kz4/YTD.pbix?dl=0

@srivally

Have you checked the YTD-MOD pbix file I shared? As my previous post, your date table doesn't contain all the possible date values of your sales table. Please change your Date table to the following:
0.PNG



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft

Thank you. I was missed it.

hi I am doing the right relationship and all the dates are popping in the datedim but when I create a table with both the relationship dates I get null in datedim column can you plz help me?

 

@v-yuezhe-msft

The datedim is a table created using DimDate = CALENDAR("1/1/2008","12/31/2020") and submit date is a another column in other table with duplicate dates. The relationship is both ways between the two column in spite of it when I try creating a table between the 2 columns I get null values for dimdate column

popov
Resolver III
Resolver III

Hello, @srivally

Did you mark your calendar table as Date Table?

@popov
I have mentioned the same, but no luck.

v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@srivally,

Please create visuals as shown in the attached PBIX file.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft
I have tried the same way, as we are having two values for single date,YTD is not getting as expected. I have attached the link to get my data in detail. Please check and help me with an idea.https://www.dropbox.com/s/nrjusedc2na7kz4/YTD.pbix?dl=0
Thanks

Hello @srivally

Try with the following measure.

 

YTD = TOTALYTD(SUM(Sales[NetSales]),VALUES('Sales'[Date]))

 

let me know if it works

@Washivale
It is working. Thank you.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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