Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pererelson
New Member

ERROR: IF Date is before Today minus two months then

Im' trying to do adapt a Excel Function, to a Query in Power Query, but I'm having a lot of trouble.

I convert the date to "RYYMMM" where "YY" are the last two digits of the month and "MMM" is the abreviation in uppercase of the Month. But the problem is when I try to put the criteria, that this format should be only applied if the date in question is before TODAY()-2 months.

The Excel Formula is the following: 

=IF(OR([@[Data de Distribuição]]="";[@[Data de Distribuição]]="MODEL");"";IF(DATE(YEAR([@[Data de Distribuição]]);MONTH([@[Data de Distribuição]]);1)<=DATE(YEAR(TODAY());MONTH(TODAY())-2;1);CONCATENATE("R";UPPER(TEXT(DATE(YEAR([@[Data de Distribuição]]);MONTH([@[Data de Distribuição]]);1);"AAMMM")));""))

 

In Power query, I'm typing this on the custom column:

if #date(Date.Year([DataPrazoCumprido]), Date.Month([DataPrazoCumprido],Date.StartOfMonth([DataPrazoCumprido]))) <= Date.AddMonths(#date(DateTime.LocalNow()), 2) then "R" & Text.End(Date.ToText(DateTime.Date([DataPrazoCumprido])),2) & Text.Upper(Date.ToText([DataPrazoCumprido],"MMM" ))
else null

The part after "then" works just fine (as shown on the highlited image), but when I try to do it with the criteria, it returns this error:

Expression.Error: 2 arguments were passed to a function which expects 1.
Details:
Pattern=
Arguments=[List]

Can anyone help me please?ERRO2.pngERRO1.png

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Pererelson ,

 

I think that you may want to use #date(year,month,day). Please refer to the following codes:

#date(Date.Year([DataPrazoCumprido]), Date.Month([DataPrazoCumprido]),Date.Day(Date.StartOfMonth([DataPrazoCumprido])))

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @Pererelson ,

 

I think that you may want to use #date(year,month,day). Please refer to the following codes:

#date(Date.Year([DataPrazoCumprido]), Date.Month([DataPrazoCumprido]),Date.Day(Date.StartOfMonth([DataPrazoCumprido])))

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
HotChilli
Super User
Super User

Missing Bracket?

Date.Month([DataPrazoCumprido],

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors