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
whulsbergen
Helper II
Helper II

custom column query editor with if, dates and max statement

How do I add a column in the query editor like I did in the "easy" add column using dax?

 

Data:

Ingevoerd opValutadatumMaatgevende boekdatumcomment
01-07-201901-01-202001-01-2020 (maxdate)
01-02-202001-01-202001-02-2020 (maxdate)
01-02-202001-01-201931-12-2019year(valutadatum) < year(ingevoerd op)

 

 

This worked:

maatgevende boekdatum = 

VAR date_1 = 'FM Budget'[Ingevoerd op]

VAR date_boeking = 'FM Budget'[Valutadatum]
VAR year_1 = YEAR(date_1)
VAR year_boeking = year(date_boeking)
VAR maxdatum = max(date_1;date_boeking)
return

IF (year_boeking<year_1;
DATE(year_boeking;12;31); // for anti-dated addings
DATE(year(maxdatum);month(maxdatum);day(maxdatum)))

 

In the query editor I have tried Add custom column using

 

if Date.Year([Valutadatum])<Date.Year([Ingevoerd op]) 
then #date(Date.Year([Ingevoerd op],31,12)
else List.Max([Ingevoerd op],[Valutadatum], type date)

but that gives an error "token comma expected"

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

It lacks final parentheses to close #date(

Also the List.Max needs a list as input. Please try this instead



else List.Max(-[Entered in],[Currency Date]))




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Employee
Employee

It lacks final parentheses to close #date(

Also the List.Max needs a list as input. Please try this instead



else List.Max(-[Entered in],[Currency Date]))




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


YES thanks!

With a little shaving to #date this was the final one:



else List.Max({[Entered on],[Currency Date]})

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.