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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
wmedin2022
New Member

Date duration with if stament

Hi All, im stuck with the follwing DAX command on my power query. I want to Days Passed to calculate the duration in days based on the status. If status is "complete" then calculate duration from date to date complete. if <> complete then calculate date to current date or Today.I

 I get this error message

 

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

 

this is my DAX

 

= Table.AddColumn(#"Extracted Month Name", "Days_Passed", each if [Status] = "Complete" then
Duration.Days([Date], [Date Closed]) else Duration.Days([Date], DateTime.LocalNow()))

 

Thanks in advance!

1 ACCEPTED SOLUTION
TomasAndersson
Solution Sage
Solution Sage

Hi!

Duration.Days expects one argument, a difference between two dates, so you need to use a minus sign instead of a comma there. You also need to convert DateTime.LocalNow() from DateTime to Date. Try something like:

= Table.AddColumn(#"Extracted Month Name", "Days_Passed", each if[Status] = "Complete" then Duration.Days([Date Closed]-[Date]) else Duration.Days(DateTime.Date(DateTime.LocalNow())-[Date]))

 

 Hope this helps!

View solution in original post

3 REPLIES 3
TomasAndersson
Solution Sage
Solution Sage

Hi!

Duration.Days expects one argument, a difference between two dates, so you need to use a minus sign instead of a comma there. You also need to convert DateTime.LocalNow() from DateTime to Date. Try something like:

= Table.AddColumn(#"Extracted Month Name", "Days_Passed", each if[Status] = "Complete" then Duration.Days([Date Closed]-[Date]) else Duration.Days(DateTime.Date(DateTime.LocalNow())-[Date]))

 

 Hope this helps!

It works!!!

Thank you

Anonymous
Not applicable

Hi @wmedin2022 

Can you share the sample data?

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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