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
epod184
Frequent Visitor

DAX Formula - cumulative price change

 

Hi All,

 

I've looked through previous posts but haven't been able to work out an answer. I'm pretty new to Power BI/DAX formula.

 

I have two tables, one is a standard dates table, with rows for each date and columns for week month year ect

 

I have a second table wich is linked by the date field, and contains Fund daily prices.

 

What I want to be able to do is have a slicer in the report, which is linked to the Date table, which controls a start and an end date.

And I want a measure to to take the 'prices_sell' value = to the end Date in slicer, and subtract 'prices_buy' value = to the start Date in the slicer

 

prices_sedol	prices_sell	prices_buy    prices_date
0001144	        6.7670	        7.2970	      2017-06-25
0001144	        6.7020	        7.2310	      2017-07-02
0001144	        6.7140	        7.2480	      2017-07-09
0001144	        6.7090	        7.2450	      2017-07-16
0001144	        6.8220	        7.3550	      2017-07-23
0001144	        6.8070	        7.3480	      2017-07-24
0001144	        6.8580	        7.3930	      2017-07-25
0001144	        6.9050	        7.4520	      2017-07-26

 

So for example if the slicer for date was 2017-07-02 to 2017-07-25, that would be:

Sell Price on 2017-07-25 less Buy Price on 2017-07-02

6.8580  -  7.2310  =  -0.373

 

please help!

 

Thanks

epod

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@epod184

You could try those measures. See more details in attached pbix.

price_buy = CALCULATE(SUM('Table'[prices_buy]),FILTER('Table','Table'[prices_date]=MIN('Table'[prices_date])))

price_sell = CALCULATE(SUM('Table'[prices_sell]),FILTER('Table','Table'[prices_date]=MAX('Table'[prices_date])))

diff = [price_sell]-[price_buy]

Capture.PNG

 

 

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee

@epod184

You could try those measures. See more details in attached pbix.

price_buy = CALCULATE(SUM('Table'[prices_buy]),FILTER('Table','Table'[prices_date]=MIN('Table'[prices_date])))

price_sell = CALCULATE(SUM('Table'[prices_sell]),FILTER('Table','Table'[prices_date]=MAX('Table'[prices_date])))

diff = [price_sell]-[price_buy]

Capture.PNG

 

 

Hi,

 

Do the need ful for below problem statement 

 

Problem Statement slicer .png

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.