Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hello Everyone!
Coluld you please convert Dax to M for me?
The formula calcalated the quatity of days in the monts and quatity of passed days in the current months minus 1.
Quantity of days =
if('Accounting Date'[Year] = YEAR(TODAY()) && 'Accounting Date'[Month] = MONTH(TODAY()),
DAY (EOMONTH ('Accounting Date'[Accounting Date], 0 ) ) -
DATEDIFF (NOW (), EOMONTH (NOW (), 0 ), DAY )-1,
DAY (EOMONTH ('Accounting Date'[Accounting Date].[Date], 0 )))
Solved! Go to Solution.
Hi @Anonymous ,
Here I suggest you to create a Custom Column in Power Query Editor by this code.
let
_Today =DateTime.Date(DateTime.LocalNow()),
_Endoftoday = Date.EndOfMonth(_Today),
_EndofAccountingDate = Date.EndOfMonth([Accounting Date])
in
if
[Year] = Date.Year(_Today)
and
[Month] = Date.Month(_Today)
then
Date.Day(_EndofAccountingDate)
-
Duration.Days(_Endoftoday-_Today)-1
else
Date.Day(_EndofAccountingDate)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Here I suggest you to create a Custom Column in Power Query Editor by this code.
let
_Today =DateTime.Date(DateTime.LocalNow()),
_Endoftoday = Date.EndOfMonth(_Today),
_EndofAccountingDate = Date.EndOfMonth([Accounting Date])
in
if
[Year] = Date.Year(_Today)
and
[Month] = Date.Month(_Today)
then
Date.Day(_EndofAccountingDate)
-
Duration.Days(_Endoftoday-_Today)-1
else
Date.Day(_EndofAccountingDate)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you, Rico
@Anonymous , Try like
if Date.EndOfMonth(DateTime.Date(DateTime.LocalNow()))= Date.EndOfMonth('Accounting Date'[Accounting Date])
then Duration.Days(DateTime.Date(DateTime.LocalNow()) - Date.StartOfMonth(DateTime.Date(DateTime.LocalNow())) ) -1
else Date.Day(Date.EndOfMonth('Accounting Date'[Accounting Date]))
As I have used Start of Month, You might not need -1
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.