Forum Discussion
AbenaMina
4 years agoNew Member
Finding Latest Values Based on 2 columns in the same table
Hi Team, I need help writing a DAX code that will give me the values in the Quantity Required field Basically, for every distinct Station_TruckNumber, I want to retrieve the Quantity of the Max C...
- 4 years ago
If you want to blank out the result of other rows then
Quantity Required = VAR LastDate = CALCULATE ( MAX ( TableName[CalendarDate] ), ALLEXCEPT ( TableName, TableName[Station_TruckNumber] ) ) VAR LastDateValue = CALCULATE ( MAX ( TableName[Quantity] ), ALLEXCEPT ( TableName, TableName[Station_TruckNumber] ), TableName[CalendarDate] = LastDate ) RETURN IF ( MAX ( TableName[CalendarDate] ) = LastDate, LastDateValue )
AbenaMina
4 years agoNew Member
All the columns belong to the same table
tamerj1
Community Champion
4 years agoYou have first to create a CalrndarYear colum. New Column >
CalrndarYear = YEAR ( TableName[CalrndarDate] )
then New Measure >
Quantity Required =
CALCULATE (
MAX ( TableName[Quantity] ),
ALLEXCEPT ( TableName, TableName[Station_TruckNumber], TableName[CalendarYear] )
)