Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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 -
Solved! Go to Solution.
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"
This seems like DAX to me. Are looking for M code ?
https://docs.microsoft.com/en-us/powerquery-m/datetime-localnow
https://docs.microsoft.com/en-us/powerquery-m/date-month
https://docs.microsoft.com/en-us/powerquery-m/date-year
In DAX we could have used these with date calendar
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
trailing Month= CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
User | Count |
---|---|
101 | |
90 | |
79 | |
70 | |
70 |
User | Count |
---|---|
112 | |
96 | |
96 | |
75 | |
72 |