Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Get max date with conditions by Query

Hi,

 

I have a Calendar table and I am trying to get max date with conditions by Query.

How can I get 1/3/2021 (max date & holiday=1)?

 

Calendar table

dateholiday
1/1/20211
1/2/20211
1/3/20211
1/4/20210
1/5/20210

 

I have try this but those are returning  1/5/2021.

 

= List.Max(Calendar[date], each [holiday]= 1)
= List.Max(Calendar[date], each [holiday]= 0)

 

 

Any help would be greatly appreciated.

  • Anonymous's avatar
    Anonymous
    3 years ago

    You could also just use Table.Max, which lets you use two parameters, like

     

    =Table.Max(PriorStepOrTableName, {"Date", "Holiday"})

     

    --Nate

3 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    =List.Max(Table.SelectRows(Calendar,each [holiday]=1)[date])

  • Anonymous's avatar
    Anonymous
    Not applicable

    You could also just use Table.Max, which lets you use two parameters, like

     

    =Table.Max(PriorStepOrTableName, {"Date", "Holiday"})

     

    --Nate