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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
ankush-vem
Frequent Visitor

DAX Calculation

Hi Team, 

I need your help in writing a dax formula to get the result from table on the right hand side. 

 

The Current table has a list of columns such as Date, No. of Shares, Close Price and Amount. The Amount column is calculated when we multiply No. of Shares and Close Price. 

 

To get the result from the Desired Result table, 

I have a Filter Option in the Power BI Report to filter out the Date. 

I would like to create a DAX Formula in Power BI which helps me to Select the Date from the Date Filter which would return the dates until the selected date and takes in consideration the Close Price of the selected date and applies the same close price for the previous dates and use that close price to multiply the no. of shares to get the results in Amount column. 

I.e., 

Formula = When clicked on the Selected Date = Apply Close Price of selected Date for the previous Dates * No. of Shares 

 

In this case, 
I have Selected the date to be 25/01/2021, where the close price is 16 and it applies to the previous dates as well to multiply the no. of shares to get the Amount as a result.

 

ankushvem_0-1643781841432.png

 

 

Thanks 

Ankush

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ankush-vem , Try a measure like

 

measure =
var _max = maxx(allselected('Date') ,[Date])
var _price = calculate(Max(Table[price]), filter(allselected(Table), Table[Date] = _max))
return
sumx(Table, Table[No of shares] * _price )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@ankush-vem , Try a measure like

 

measure =
var _max = maxx(allselected('Date') ,[Date])
var _price = calculate(Max(Table[price]), filter(allselected(Table), Table[Date] = _max))
return
sumx(Table, Table[No of shares] * _price )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amitchandak,
Thank you for your reply and it retuns a value but no way of seeing its correct or wrong. Can we split this messure into two? one for the selected date's close price and then we can multiply it by the no of shares?

Also can you advise on how we can filter the ledger records on and before the selected date.
Thank you,
Uthpala

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.