Forum Discussion

Rohini's avatar
Rohini
Helper I
6 years ago
Solved

Power Query Editor - Current Month Issue

Reporting values during a current month requires pulling data pertaining to previous month i.e., during March, I need to extract data from the field [Feb 2020], in April, I need to extract data from the field [Mar 2020] and so on...

 

The following formula works in a query but not in power query - 

 

Current_Month = If (MONTH(TODAY())=3, [Feb 2020], (
            If (MONTH(TODAY())=4, [Mar 2020], (
If (MONTH(TODAY())=5, [Apr 2020], (
            If (MONTH(TODAY())=6, [May 2020], (
            If (MONTH(TODAY())=7, [Jun 2020], (
            If (MONTH(TODAY())=8, [Jul 2020], (
            If (MONTH(TODAY())=9, [Aug 2020], (
            If (MONTH(TODAY())=10, [Sep 2020], (
If (MONTH(TODAY())=11, [Oct 2020], (
If (MONTH(TODAY())=12, [Nov 2020], "999999999")))))))))))

))))))))
 
Can someone help me on how to extract the current month in power query editor?
  • Hi Rohini 

    for Power Query use Date.Month(DateTime.LocalNow()) function

    like

    = if Date.Month(DateTime.LocalNow())=3 
    then [Feb 2020]
    else if Date.Month(DateTime.LocalNow())=4
    then [Mar 2020]
    else "999999999" 
    
    

2 Replies