Forum Discussion

nok's avatar
nok
Advocate II
1 year ago
Solved

Check scale based on most recent minor date

Hello! I have two tables that follow this structure: ProductsTable ID RequestDate   Amount 111 23/06/2025 1000 111 24/06/2025 1010 111 19/07/2025 300 222 11/10/2025 500 ...
  • Demert's avatar
    1 year ago

    Hi nok ,

     

    Following dax code for a new calculated column should work :

    InScale = 
    VAR _A = SUMMARIZE(FILTER(ScaleTable,ScaleTable[ID]=EARLIER(ProductTable[ID])), ScaleTable[ID],"@MaxDate", CALCULATE(MAX(ScaleTable[StartDate]),   ScaleTable[StartDate]< EARLIER(ProductTable[RequestDate])))
    
    VAR _MaxDate = MAXX(_A,[@MaxDate])
    
    VAR _Scale= CALCULATE(MAX(ScaleTable[Scale]), _MaxDate= ScaleTable[StartDate])
    RETURN IF(_Scale = ProductTable[Amount] , TRUE() , FALSE())

     

    We are creating a virtual table (summarize) of the scale table to only match the selected ID of the row in the product table where the max start date is before the requested date. Then we calculate the Scale of that date and look if the amount matches