Equation Editor vs Custom Function

IDEAScripting.com
5 Mar 202314:06

Summary

TLDRIn diesem Video zeigt der Sprecher zwei Methoden, wie man ein unformatiertes Datumsfeld in ein nutzbares Format umwandeln kann. Die erste Methode verwendet den Gleichungseditor, um das Datum mit einer komplexen Gleichung zu reformatieren. Die zweite Methode nutzt eine benutzerdefinierte Funktion, die entweder in der Idee-Skriptsprache oder Python geschrieben werden kann. Der Vorteil der benutzerdefinierten Funktion liegt in ihrer Lesbarkeit und Flexibilität, da sie auch für komplexere Aufgaben eingesetzt werden kann. Der Sprecher erklärt beide Methoden detailliert und zeigt, wie sie in der Datenbank implementiert werden.

Takeaways

  • 📅 Das Video zeigt zwei Methoden, um ein unformatiertes Datumsfeld in ein nutzbares Format zu konvertieren.
  • 🔢 Die erste Methode verwendet den Gleichungseditor, um das Datumsfeld umzuformatieren.
  • 📝 Die Umformatierung erfolgt durch die Verwendung der Funktion 'character to date' und erfordert das Hinzufügen von Trennzeichen.
  • 🔄 Die Umformatierungslogik ist in der Gleichung mehrfach wiederholt, was zu einer langen und manchmal schwer lesbaren Gleichung führt.
  • 🎨 Die zweite Methode ist die Verwendung einer benutzerdefinierten Funktion, die entweder in ID-Script oder Python geschrieben werden kann.
  • 📚 Benutzerdefinierte Funktionen ermöglichen es, direkt mit der Datenbank über virtuelle Felder zu interagieren.
  • 🔍 In ID-Script sind die meisten Funktionen des Gleichungseditors verfügbar, indem man das '@'-Symbol durch das 'I'-Symbol ersetzt.
  • 📊 Die benutzerdefinierte Funktion kann mit mehr Komplexität und Lesbarkeit umgesetzt werden als die Gleichungseditormethode.
  • 🔧 Die benutzerdefinierte Funktion kann auch Schleifen und Python-Befehle verwenden, was eine breitere Funktionalität ermöglicht.
  • 📆 Am Ende der Umformatierung kann das umgeformte Datumsfeld mit der 'character to date'-Funktion in ein Datumsfeld konvertiert werden.
  • 📈 Die benutzerdefinierte Funktion liefert das gleiche Ergebnis wie die Gleichungseditormethode, aber mit einer besseren Lesbarkeit und Flexibilität.

Q & A

  • Was ist das Ziel des in der Videobeschreibung erwähten Prozesses?

    -Das Ziel ist, ein Datumsfeld im nicht korrekten Format in ein für die Verwendung in IDEA geeignetes Format zu konvertieren.

  • Welche beiden Methoden werden im Video zur Formatierung des Datumsfelds verwendet?

    -Die beiden Methoden sind die Verwendung des Gleichungseditors und die Erstellung einer benutzerdefinierten Funktion.

  • Was ist der Vorteil der benutzerdefinierten Funktion im Vergleich zum Gleichungseditor?

    -Die benutzerdefinierte Funktion ist in der Regel lesbarer und ermöglicht es, komplexere Gleichungen und Schleifen zu verwenden. Zudem hat man mit der Möglichkeit, Python-Befehle zu verwenden, Zugriff auf eine breitere Funktionalität.

  • Wie wird die Funktion 'character to date' im Gleichungseditor verwendet?

    -Die Funktion 'character to date' wird dazu verwendet, um eine Zeichenfolge in ein Datum zu konvertieren, indem sie in das gewünschte Format (Tage-Monats-Jahres) umgestaltet wird.

  • Welche Schritte unterliegt die ursprüngliche Zeichenfolge im Gleichungseditor?

    -Die ursprüngliche Zeichenfolge wird in Teile aufgeteilt, um das Jahr, den Monat und den Tag zu identifizieren, und anschließend entsprechend formatiert, um das Datum korrekt darzustellen.

  • Wie wird die Länge der Zeichenfolge im Gleichungseditor überprüft?

    -Die Länge der Zeichenfolge wird überprüft, um zu bestimmen, ob das Jahr zwei oder vier Ziffern lang ist und ob der Monat eine Ziffer oder zwei Ziffern hat. Auf diese Weise wird die Zeichenfolge entsprechend formatiert.

  • Was ist die Funktion von 'I split' in der benutzerdefinierten Funktion?

    -Die Funktion 'I split' wird verwendet, um die ursprüngliche Datumszeichenfolge anhand von Trennzeichen (Hyphens) in ihre Bestandteile zu unterteilen.

  • Wie wird im Gleichungseditor die Konvertierung von Zeichen in ein Datum erreicht?

    -Die Konvertierung wird durch die Verwendung der 'character to date'-Funktion erreicht, die die formatierte Zeichenfolge in ein Datum umwandelt.

  • Welche Art von Funktionen sind in der benutzerdefinierten Funktion verfügbar?

    -In der benutzerdefinierten Funktion sind die meisten Funktionen aus der Gleichungseditor-Version bis zur Version 9 von IDEA verfügbar, einschließlich der 'I split'-Funktion.

  • Wie wird die benutzerdefinierte Funktion in der Datenbank implementiert?

    -Die benutzerdefinierte Funktion wird als virtueller Datumsfeld in der Datenbank implementiert, wobei sie mit der 'character to date'-Funktion in der Gleichungseditor verknüpft wird.

  • Welche Python-Befehle können in benutzerdefinierten Funktionen verwendet werden?

    -Mit der Möglichkeit, Python-benutzerdefinierte Funktionen zu erstellen, haben Sie Zugriff auf alle Python-Befehle, was eine breitere Funktionalität im Vergleich zum Gleichungseditor bietet.

Outlines

00:00

📅 Formatting Date Fields in IDEA

The speaker explains how to format a date field in IDEA that is not in the standard format. They mention two methods: using the equation editor and creating a custom function. The first method involves using a character to date function to reformat the date into a usable format. The speaker also discusses the drawbacks of this method, such as code reuse and readability. They then demonstrate how to create a new virtual date field and use the equation editor to apply the reformatting equation.

05:03

🔧 Custom Function for Date Formatting

The speaker introduces the concept of custom functions in IDEA, which allows for direct interaction with the database using iScript or Python. They guide through the process of creating a custom function named 'date change' to reformat a character date field. The speaker explains how to split the date string into year, month, and day components, handle different date formats, and then reassemble them into a standard format. They also mention the benefits of custom functions, such as readability and the ability to use loops and Python commands.

10:03

🔗 Applying Custom Functions and Equation Editor

The speaker concludes by demonstrating how to apply the custom function to the date field and use the character to date function within the equation editor to convert the formatted character field into a date field. They highlight the advantages of custom functions for complex equations and the additional functionality provided by Python custom functions, wrapping up the tutorial with a successful validation and application of the date formatting techniques.

Mindmap

Keywords

💡Date Field

In the context of the video, a 'Date Field' refers to a data field that contains date information. The speaker discusses how to format this field properly so it can be used effectively in a database or software like IDEA. The date field is expected to be in a standard format such as 'YYYY-MM-DD', but the speaker is dealing with a non-standard format that needs to be corrected.

💡Equation Editor

The 'Equation Editor' is a tool within the IDEA software that allows users to create or modify equations. It is used to transform the non-standard date field into a standard format. The speaker demonstrates how to use the Equation Editor to apply a formula that reformats the date field.

💡Custom Function

A 'Custom Function' in the video refers to a user-defined function created within the IDEA software using either IDEA Script or Python. This function can interact directly with the database and is used to perform complex operations on data, such as reformatting dates.

💡Character to Date

The 'Character to Date' function is used to convert a string of characters representing a date into a date object that the software can understand and work with. This is crucial in the process of reformatting the date field, as it allows the software to recognize and use the date information correctly.

💡IDEA Script

IDEA Script is a scripting language used within the IDEA software for automating tasks and performing complex data manipulations. It is one of the options for creating Custom Functions, allowing users to write scripts that can interact with the database.

💡Python Custom Function

A 'Python Custom Function' is a function created using Python, a widely-used programming language, within the IDEA software. This function can be used to perform more advanced operations and leverages the full power of Python, offering additional functionality beyond what IDEA Script can provide.

💡Reformatting

In the video, 'Reformatting' refers to the process of changing the structure or format of data, specifically dates, to make it compatible with the software's requirements. This is necessary when the date data is not in the expected format.

💡Virtual Date Field

A 'Virtual Date Field' is a field created within the software that does not physically exist in the database but is generated on-the-fly based on calculations or transformations of existing data. In this case, it is used to display the reformatted date in a usable format.

💡I-Split

The 'I-Split' function, similar to the 'AT SPLIT' function in the Equation Editor, is used in IDEA Script to split a string into parts based on a specified delimiter. It is used in the Custom Function to separate the year, month, and day components of the date.

💡I-String

The 'I-String' function in IDEA Script is used to manipulate strings, such as extracting a substring or finding the position of a character within a string. It is used in the Custom Function to locate and extract the date components.

Highlights

The speaker is discussing how to format a date field in an idea management system.

The date field needs to be in a standard format like years, months, and days.

The speaker will demonstrate two methods to format the date field: using the equation editor and a custom function.

The preferred method for complex scenarios is usually the custom function.

Creating a new virtual date field called 'idea date'.

Using the 'character to date' function to reformat the date.

The equation editor is used to develop a formula for date reformatting.

The custom function approach is introduced as an alternative to the equation editor.

Custom functions allow direct interaction with the database using iScript or Python.

The custom function 'date change' is created to reformat the date field.

Variables are created to hold the year, month, and day parts of the date.

The 'split' function is used within iScript to handle different date formats.

The speaker explains how to handle cases where the year is given in two or four digits.

The month and day parts of the date are reformatted to ensure they are two digits each.

The reformatted date parts are combined to create a standard date format.

The custom function is tested and validated within the idea management system.

The speaker compares the custom function method to the equation editor, highlighting the readability and functionality advantages.

The addition of Python custom functions expands the capabilities of the system.

Transcripts

play00:00

foreign

play00:01

[Music]

play00:09

good day everyone in this second part

play00:12

what I'm going to do is I'm going to

play00:14

take a date field that isn't really in

play00:18

an idea format

play00:19

so as we can see here that the date

play00:22

field generally it wants to be in years

play00:26

months day or something similar to that

play00:28

you know with two digits for the year

play00:31

sorry four digits for the year two

play00:33

digits for the month and two digits for

play00:34

the day so we're missing the proper

play00:36

formatting to actually be able to use

play00:39

this properly in idea

play00:41

so I'm going to show you two ways how we

play00:43

can format this one with the equation

play00:46

editor and the other one uh using a

play00:50

custom function

play00:52

my preference generally adds scenarios

play00:55

like this is usually a custom function

play00:56

and I'll sort of show you why and you

play01:00

know as we go along and hopefully it'll

play01:02

actually be obvious

play01:04

so I'm just going to first create a new

play01:06

field

play01:07

I'm just going to call this idea date

play01:12

and I'm going to make this a virtual

play01:14

date field

play01:16

then we'll bring up the equation editor

play01:19

so I'm going to make this a bit larger

play01:23

and I've already developed this equation

play01:25

or actually

play01:27

the person who sent me this had already

play01:29

developed this so I'm just going to

play01:31

reuse this

play01:32

so you could sort of see how it works

play01:36

and we'll go about explaining it I think

play01:38

it'll probably be easier to explain than

play01:40

every than anything else

play01:42

uh so the first function here is

play01:45

character to date so this is taking a

play01:47

character

play01:48

uh and changing it to a date so all this

play01:54

part here is actually

play01:59

taking

play02:01

this date here and reformatting it so we

play02:05

could use the character to date function

play02:07

so what we're doing is we're returning

play02:09

this function in here so that it has two

play02:12

digits for the day with a dash two

play02:15

digits for the M with a dash and four

play02:17

digits for the year so the first part is

play02:20

the day so we're using a lot if here and

play02:23

what we're doing here is we're seeing

play02:25

okay if the length of the first

play02:29

characters are everything up to the

play02:31

first hyphen hyphen here is only length

play02:35

of one then we add on a zero to it if

play02:39

not then we take everything up to the

play02:42

one

play02:44

so that is this part here it gives us

play02:50

the date

play02:51

sorry not the date that gives us the day

play02:55

then we're including the hyphen

play02:58

then the next part is we're doing the

play03:00

same thing here we're using the at split

play03:03

to figure out if the month

play03:06

is actually one character and if it's

play03:10

one character then we're adding on a

play03:11

zero to it if not we're using it

play03:14

so everything

play03:18

from here to here is related to

play03:22

reformatting the month into two digits

play03:25

and finally here we are doing the same

play03:29

thing for the

play03:31

sorry for the year uh there's extra code

play03:34

here where where somebody okay the date

play03:38

could be two digits in which case we add

play03:41

on the 20 if not we use the the whole

play03:45

date

play03:45

so what this will give us is something

play03:47

that will be day day Dash mm Dash WHYY

play03:52

which is this format here

play03:56

and then using the character to date

play03:57

we'll take this character this

play04:00

reformatted character and turn it into a

play04:04

date

play04:05

now as you can see one of the problems

play04:07

here is that we are

play04:10

you know reusing the code over and over

play04:13

again so it makes it kind of long and

play04:15

remote and also the way it winds through

play04:18

here it's kind of sometimes hard to read

play04:19

but it works so we can try this out it's

play04:22

a valid equation

play04:25

and then I just click on OK and let's

play04:27

see how this works

play04:30

and here we've got the reformatted field

play04:33

so now this is actually in a format of a

play04:35

date field so now you can use any of the

play04:38

usual IDF functions or analytics on this

play04:42

date field

play04:44

the second way I'm going to do this is

play04:46

through a custom function

play04:48

so again a custom function is through

play04:50

the equation under so I'm going to add

play04:52

on another date field

play04:56

call this CF

play04:58

again this will be another date field

play05:02

but instead of creating this in the

play05:05

equation editor I'm going to create it

play05:07

as a custom function so a custom

play05:09

function allows you to use idscrip or

play05:12

python to create functions that will

play05:16

interact directly with your database

play05:18

through virtual fields

play05:21

so I'm going to do a custom function so

play05:23

I'm going to click click on new

play05:25

so here I got the the uh I can use

play05:28

either a custom custom function which

play05:30

would be an idea script or the python

play05:32

custom function the distance is I'm

play05:34

going to use the idea script one

play05:36

and this brings me up the editor I'm

play05:39

just going to make this a bit larger so

play05:41

first off I've got to give this a

play05:43

function name

play05:44

and I'm just going to call this date

play05:46

change

play05:48

then I gotta select the number of

play05:50

parameters so we get our multiple

play05:53

parameters here in this instance I only

play05:55

want one parameter namely the that date

play05:57

field but that date field is in a

play06:00

character format so we're going to

play06:01

select character

play06:03

and I can add on some help tasks and

play06:05

change the name if I want but I'm just

play06:06

going to leave it for the defaults for

play06:08

this demonstration

play06:10

I click on OK

play06:12

and now I start writing the

play06:15

the item

play06:16

so we also have a way to test the

play06:18

equation so suppose I want to go in and

play06:21

test the equation so suppose I want to

play06:23

go in where we want to say

play06:26

you know January 6

play06:29

you know 2023.

play06:33

so that's going to be our test

play06:35

first thing I want to do to this is I

play06:37

want to create variables to hold the

play06:39

different parts of the date

play06:41

so I'm going to

play06:43

create a variable

play06:45

to hold the year create a variable to

play06:48

hold them a month and create a variable

play06:50

to hold the date

play06:52

so these are all strings because we want

play06:54

the characters

play06:56

because it's being so this is basically

play06:58

a character field so I'm using character

play07:01

variables to hold the different

play07:02

information

play07:04

now if I want to use the year

play07:09

easy enough I can just use yes ear

play07:12

equals 2. so on the S here here I don't

play07:15

know whether it's going to be two

play07:17

characters or four characters so what

play07:19

I'm going to do is like sort of the same

play07:21

thing as we did in uh the equation

play07:23

editor is I'm going to use up the I

play07:26

split the split function so you may not

play07:29

be aware of this but the majority of the

play07:32

at functions within the equation editor

play07:36

are also available within idea script by

play07:40

replacing the at symbol with the I

play07:42

symbol so basically all functions that

play07:45

were created

play07:47

up to uh Version 9 of idea

play07:52

are available

play07:54

so the split function is one of them so

play07:57

I can use that

play08:02

so the Iceland is first off is I use the

play08:05

the variables so the P1 so this is

play08:07

holding the original date

play08:09

then I am looking for the hyphen

play08:13

and then basically the end so basically

play08:16

putting two double quotes with nothing

play08:19

in between means that it's either the

play08:21

end or the beginning of the variable

play08:24

depending on how you use it in this

play08:25

instance because it's placed there it

play08:27

means it's to the end and as there's two

play08:30

hyphens there I'm saying I start from

play08:32

the second one and going to the end

play08:36

and we can see the track of that works

play08:38

by basically doing big change so the

play08:42

name of the function equals to the S

play08:44

here

play08:45

and then if I go click on test

play08:49

it gives me 2023.

play08:52

now the next thing I want to do is what

play08:54

happens if it's only 23.

play08:58

so in that instance then I just do this

play09:01

year I'm sorry I'm going to do an if

play09:04

if length s

play09:08

the ears off the length is equal to

play09:09

totally two characters

play09:12

then it is equal to I want to add on

play09:17

20

play09:19

plus the ear

play09:22

so if I try that

play09:25

so it gives me 2023 which is the one I

play09:27

want

play09:28

so that's the first one now let's do the

play09:30

the month

play09:33

oops

play09:35

and again here as I'm going to use the I

play09:37

splits

play09:41

for this time I'm going to use instead

play09:44

of the empty quotes I'm going to use

play09:46

hyphen hyphen and a one so what this

play09:49

means is I'm splitting everything

play09:50

between

play09:52

the first hyphen and the second hyphen

play09:55

so the one means it's the first one

play09:57

and again here I'm going to just check

play09:59

and see whoops

play10:03

the length here

play10:07

equals one

play10:10

then we add on a zero

play10:13

whoops

play10:18

two of the months

play10:21

and now if I try this let's see what we

play10:23

get

play10:25

zero and perfect and the final one is

play10:29

the day

play10:32

and today we can do this a bit

play10:34

differently I'm going to do this a bit a

play10:37

little bit differently so instead of

play10:39

using because the days always the first

play10:41

characters I could use a left

play10:44

and I can say Okay I want anything left

play10:47

starting from the first character and

play10:49

then I'm going to locate the first time

play10:51

that the hyphen shows up and how I do

play10:54

that is a function called in string

play11:00

and I'm going to say I want this as the

play11:02

first character

play11:03

and actually this is not a one I just

play11:05

realized this is P1

play11:07

so this is the variable that we'll be

play11:09

looking at so here I'm going to be

play11:11

looking at the starting from the first

play11:13

character in the variable P1

play11:18

with the hyphen

play11:20

and I'm going to have to subtract one

play11:23

reason being is that

play11:26

here it's the second character but I

play11:28

only want one so I have to subtract 1 in

play11:32

that instance and then again I just do

play11:34

the

play11:35

the length again

play11:39

equals one then as day equals

play11:43

oops

play11:49

and now we're going to try this out make

play11:52

sure the day is working right

play11:55

and so it is and then it's just a matter

play11:57

of putting it together

play11:59

so what we want is we want the year

play12:04

plus the month

play12:08

plus today

play12:11

and we test that out so it's giving me

play12:14

the proper format

play12:16

so I'm still returning a character field

play12:18

but now I can use the character to date

play12:22

function within the equation editor and

play12:24

also I'm going to add the category here

play12:26

I'm going to add this as a date time

play12:29

so here let me go I can go and validate

play12:31

so there's no errors

play12:34

I'll save it

play12:35

I'll exit out of this here I'll exit out

play12:38

of the custom functions so now if I go

play12:41

into custom functions under date time we

play12:45

can see we got the date change here

play12:47

so I'll use that

play12:49

and I'm using that on the date

play12:53

and I'm going to wrap this around the or

play12:56

actually use the

play12:58

character

play13:00

to date

play13:04

and I'll just show the format is yyy

play13:06

mmdd

play13:09

to change it to a date field

play13:11

and the validations is okay I click on

play13:17

this and it process a dialog

play13:23

and now you can see that the custom

play13:26

function

play13:29

gives you the same result

play13:31

as the equation editor for me it's just

play13:34

the custom function to when the

play13:36

equations are a bit more complicated I

play13:38

prefer custom functions because I find

play13:40

they're a bit more readable plus also

play13:42

for more advanced items you can also use

play13:44

Loops in there and now with uh the

play13:49

addition of being able to create python

play13:52

custom functions you also have access to

play13:55

all the uh you know python command so

play13:58

that opens up a whole bunch of other

play14:00

functionality that you can do within the

play14:03

equation editor and custom functions

play14:04

thanks

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
DatenformatierungGleichungseditorBenutzerdefinierteFunktionDatenanalyseIDEASchrittweiseAnleitungDatenverarbeitungProgrammierungIDEAScriptPython
هل تحتاج إلى تلخيص باللغة الإنجليزية؟