Forum Discussion
rustice
8 years agoFrequent Visitor
Get value from row in the same table based on last date
How can I return the amount based on last date for a specific customer using DAX? Here is a sample data: In this case, I want Customer A for each Services Contract to return its near...
- 8 years ago
Hey,
assuming you want to create a calculated column you can solve your question by doing this:
- create a var that stores the current customer
- create a var stat stores the currnent date
- create a var stat stores the type of contract
use the above information to find the "max" date of all the dates that are smaller than the current date, store this date in a variable
The DAX statement will look similar to this
var latestDate = CALCULATE( MAX('tablename'[Startdate]) ,FILTER( ALL('tablename') ,'tablename'[Parent Customer] = varCurrentCustomer && ... && 'tablename'[Start Date] < varCurrentDate )Now use this variable together with the other variables to determine the Net Amount, just change part to the condition inside the FILTER() to
,'tablename'[Parent Customer] = varCurrentCustomer && ... && 'tablename'[Start Date] = latestDate
If you have further questions please provide sample data, create a pbix file, upload the file to onedrive or dropbox and share the link to the file
Regards,
Tom