Extract Year from Date Column in the layout using algorithm.

Malav Shelat
Malav Shelat Customer
Second Anniversary
edited April 2020 in Platform

Hello all,

 

Is it possible to extract year from Date cube (the First Column in the Image) by using trim, Right/Left, Year function ?! 

by creating a Column algorithm in the layout itself ?

 

I am trying to get that and used various combinations of the same but no luck.

 

can any one please guide ?!

 

for example:

In the image below there is a  first Column with Date, i just need to extract Year from it and display in last column.

 

image

 

Looking for help on this one.

 

Warm Regards,

Malav 

Answers

  • Mateo DE LOS RIOS
    Mateo DE LOS RIOS Active Partner
    Second Anniversary First Comment 5 Up Votes
    edited March 2020

    Hi Malav,

     

    From what i see the "Year" function works for the ETL Datareader and Nexel.

    You can try to test the "Nexel" functionalitie. 

    To use it, set your column algorithm formulas to "Single rule" : 

    image

    Then, click on "Edit formulas" in the layout sliding toolbar : 

    image

    Then double click on the desired cell, edit the formula and save : 

    image

     

    Close the pop-up and your cell should show you the year.

    image

     

    Let me know if it's helping.

     

    Best regards,

     

    Mateo DE LOS RIOS

  • Hi Malav Shelat,

     

    why don´t you use an algorithm with right(a,4) - a is the block with the date - and set it to text to avoid the "." for thousend ?

    You can also use the Excel mid function if you have a datetime in block a.

     

    BR

    Dietmar

  • Hi Dietmar Jeschkeit,

     

    right(a,4) wont work, already tried along with formatting as well. No Luck.

     

    thanks for the reply

     

    regards,
    Malav

  • Hi Mateo DE LOS RIOS,

     

    Thank you for your reply, actually i was aware about this Nexel function but i was just hoping if we could do this without nexel as i want to use that in procedure Dataflows. Is that possible in our Layout itself with Column Algorithm and not using nexel.

     

    do you think that's possible ? 

     

    Regards,

    Malav

  • Paul Wyatt
    Paul Wyatt Customer
    100 Comments 100 Up Votes 100 Likes Second Anniversary
    edited March 2020

    Hi Malav,

     

    I have not read  the complete thread so excuse me if I missed the point but It looks like you're treating a figure as a text value.  If so, you must make the destination datatype 'text' also.  Image 1 shows the NEXEL formula =year([@a;*;*]) in columns b and c.  Column b is a text cube but could easily be a block created within NEXEL and then changed to datatype: TEXT.

     

    The reason I illustrate a cube is because I also wanted to say that NEXEL can be used server-side as an alternative to dataflows.  Used this way, NEXEL becomes a very powerful ETL tool.

     

    Image 1 the NEXEL formula =year([@a;*;*]) has been placed in columns b and c.  Column b is a TEXT cube whilst Column c is a numeric column. 

    image

     

    Hope this helps

  • Sorry,

     

    I forgot it´s a date cube. The date internal in BOARD is like in Excel 1 for 1.1.1900 and then +1 for each day. That's why, of course, the year doesn't come with right(a,4). 

  • Hi Paul Wyatt - Avison Young UK,

     

    Thank you for your reply, actually i am aware about this Nexel function but i was just hoping if we could do this without nexel as i want to use that in procedure Dataflows. Is that possible in Layout itself with Column Algorithm and not using nexel.

     

    do you think that's possible ? 

     

    Regards,

    Malav

  • Hi Malav,

     

    Looks like it's possible in a column algorithm by reproducing Excel number format logic. That is to say divide the date value by 365.25 and adding 1900 :

     

    trunc((a-1)/365.25+1900)

     

    The -1 is for 31st december that would give next year without it. Tried it with several dates and seem to be always working.

  • HI, 

    A simple way is to set a block into the dataview with the entity year. Simple and smart ;-)

  • Hi Pietro,

     

    but the Question was extracting the year from a date cube. And the block with Entity year will only work if you have the time by row.

  • Hi Basil Henrion,

     

    Thank you very much for helping out, this is exactly the solution i was looking for.

     

    Warm regards,

    Malav