Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

M Query for Previous Year MTD

Hi,

Please help me in getting Previous Year MTD in M query.

My date field is [Transaction Detail.Production Period].

 

I was able to get the PYYTD using:
#"FILTER"=Table.SelectRows(#"Changed Type",each (Date.Year([Transaction Detail.Production Period]) =Date.Year(DateTime.LocalNow()) -1 ))
in
#"FILTER"

but please help in getting PYMTD.

 

Thanks

Vaibhav

  • Anonymous , Try like

     

    #"FILTER"=Table.SelectRows(#"Changed Type",each (Date.Year([Transaction Detail.Production Period]) =Date.Year(DateTime.LocalNow()) -1 and Date.Month([Transaction Detail.Production Period]) =Date.Month(DateTime.LocalNow()) ))
    in
    #"FILTER"

2 Replies

  • Anonymous , Try like

     

    #"FILTER"=Table.SelectRows(#"Changed Type",each (Date.Year([Transaction Detail.Production Period]) =Date.Year(DateTime.LocalNow()) -1 and Date.Month([Transaction Detail.Production Period]) =Date.Month(DateTime.LocalNow()) ))
    in
    #"FILTER"

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Amit,

      Currently i am duplicating the Policy table and adding these conditions there, but now i need to display the Premium MTD, YTD, PYMTD and PYYTD in different columns in report and the Premium is coming from different table. 

      How can i display the same , do i need to append all with Premium table into one or whats the other alternative.

      Sorry i am new to this.

      Thanks

      Vaibhav