cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
srivally Regular Visitor
Regular Visitor

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

Accepted Solutions
Moderator v-yuezhe-msft
Moderator

Re: Calculate YTD for duplicate dates

@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.
14 REPLIES 14
Moderator v-yuezhe-msft
Moderator

Re: Calculate YTD for duplicate dates

@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.
popov Member
Member

Re: Calculate YTD for duplicate dates

Hello, @srivally

Did you mark your calendar table as Date Table?

srivally Regular Visitor
Regular Visitor

Re: Calculate YTD for duplicate dates

@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

srivally Regular Visitor
Regular Visitor

Re: Calculate YTD for duplicate dates

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

Washivale Regular Visitor
Regular Visitor

Re: Calculate YTD for duplicate dates

Hello @srivally

Try with the following measure.

 

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

 

let me know if it works

Moderator v-yuezhe-msft
Moderator

Re: Calculate YTD for duplicate dates

@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.
srivally Regular Visitor
Regular Visitor

Re: Calculate YTD for duplicate dates

@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 Regular Visitor
Regular Visitor

Re: Calculate YTD for duplicate dates

@Washivale
It is working. Thank you.

Moderator v-yuezhe-msft
Moderator

Re: Calculate YTD for duplicate dates

@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.