Forum Discussion

usernj123's avatar
usernj123
New Member
2 years ago
Solved

Max from related table

Hello All, I have 2 tables as shown below. Months table: (MonthName is text) TechSpend: MonthName      Text Category   Text Year          Text Actuals     Currency   TechSpend table ha...
  • nsexton12's avatar
    2 years ago

    I agree with the above comment about creating a proper date table! However, below is a solution anyway. 

    ----------------------------------------------------------------

    VAR FilteredVirtualTable =TOPN(1,FILTER(SUMMARIZE(Months,Months[MonthsName],Months[MonthNum]),Months[MonthsName] IN VALUES(TechSpend[MonthsName])),Months[MonthNum])

    VAR MonthNameVirtalTable = SELECTCOLUMNS(FilteredVirtualTable,"Month Name",Months[MonthsName])

    RETURN MonthNameVirtalTable 
    ----------------------------------------------------------------
     
     
    You needed to add one more step by creating a virtual table that is all matching rows between your months table and tech spend table, and then take the top row of that table after it is sorted by month number. The last step is using the selected columns function to grab the name of the month from that table. 
     
    Please mark as a solution if this worked for you!