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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
stella1215
Frequent Visitor

Calculate daily return rate

hello everyone!

 

I want to add a calculated column of the daily return rate by the company. My data looks like below. I want to use today's price divided by yesterday's price, and so on. For example, 2021.4.7's price / 2021.4.6's price. How can I achieve this?

 

Thank you!

 

DatecompanyPrice
2021.4.66000018.51
2021.4.76000019.41
2021.4.86000019.1
2021.4.66000029.88
2021.4.760000210.78
2021.4.860000210.52
2021.4.660000310.62
2021.4.760000310.32
2021.4.860000310.43
1 ACCEPTED SOLUTION

Hi, @stella1215 

Please check the below picture and the sample pbix file's link down below.

 

Picture3.png

 

Daily Return Rate Measure =
VAR currentdate =
MAX ( Data[Date] )
VAR currentcompany =
MAX ( Data[company] )
VAR previousdate =
CALCULATE (
MAX ( Data[Date] ),
FILTER ( ALLEXCEPT ( Data, Data[company] ), Data[Date] < currentdate )
)
VAR previousprice =
CALCULATE ( [Today Price], Data[Date] = previousdate )
RETURN
DIVIDE ( [Today Price], previousprice, BLANK () )

 

 

https://www.dropbox.com/s/oi2fqd0cn62e0gq/stella1215.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, @stella1215 

 

Please try the below calculated column.

 

Daily Return Rate Column =
DIVIDE (
Data[Price],
VAR previousdate =
CALCULATE (
MAX ( Data[Date] ),
FILTER (
ALLEXCEPT ( Data, Data[company] ),
Data[Date] < EARLIER ( Data[Date] )
)
)
RETURN
CALCULATE (
SUM ( Data[Price] ),
FILTER ( ALLEXCEPT ( Data, Data[company] ), Data[Date] = previousdate )
),
BLANK ()
)

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you for your help! I have another question: is it possible to achieve this in a measure? I applied your DAX to get that calculated column. Since my dataset is kinda big, it slowed down the entire report compared to when I directly import the return rate. I was wondering if making it a measure can do the same trick and speed the loading process?

Anonymous
Not applicable

Hi @stella1215 

 

You should not have it as a measure. You should use Power Query to calculate this. The DAX given by @Jihwan_Kim for the calculation of the column is slow because one should never use CALCULATE when creating columns in DAX. CALCULATE executes context transition on every row in the table and this is a very expensive operation. Your column can be calculated in DAX without CALCULATE but I would do it in Power Query since this is where the calculation truly belongs and it's the best solution for many reasons.

Hi, @stella1215 

Please check the below picture and the sample pbix file's link down below.

 

Picture3.png

 

Daily Return Rate Measure =
VAR currentdate =
MAX ( Data[Date] )
VAR currentcompany =
MAX ( Data[company] )
VAR previousdate =
CALCULATE (
MAX ( Data[Date] ),
FILTER ( ALLEXCEPT ( Data, Data[company] ), Data[Date] < currentdate )
)
VAR previousprice =
CALCULATE ( [Today Price], Data[Date] = previousdate )
RETURN
DIVIDE ( [Today Price], previousprice, BLANK () )

 

 

https://www.dropbox.com/s/oi2fqd0cn62e0gq/stella1215.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.