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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Split multiple years date column to multiple lines graph it

Hello,

 

I am a fresh new user and want, from a data set with a column timestamp with multiple years (2015, 2014, 2013...), to produce a graph to compare events between the years.

 

Any idea on how to do it ?

Please ask if i am not clear

 

Thank you

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

If your [TS col] column can be transformed to "date" type and format as below without any error,

Capture1.JPG

If not, please spilt your [TS col] column as @amitchandak  suggested, or you could split it in power query like the following:

Capture2.JPG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XcrJCQAgDATAXvYtmMS7Fkn/bWhQIfgcmDkhJBRZEFCg4Zm3szNtj2se51dn/8325bl/v5/fnO0nqC4=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"TS col" = _t, Values = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "TS col", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"TS col.1", "TS col.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"TS col.1", Int64.Type}, {"TS col.2", Int64.Type}, {"Values", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"TS col.1", "year"}, {"TS col.2", "month"}}),
    #"Inserted Merged Column" = Table.AddColumn(#"Renamed Columns", "date format", each Text.Combine({Text.Combine({Text.From([year], "en-US"), Text.From([month], "en-US")}, "/"),Text.From(1,"en-US")},"/"), type text),
    #"Changed Type1" = Table.TransformColumnTypes(#"Inserted Merged Column",{{"date format", type date}})
in
    #"Changed Type1"

Then close&&apply, create a date table, add columns to visuals as below

Capture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

The best way would be to split your date/time to date and time columns and create a date dimension/calendar table like in the article below.

 

https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

amitchandak
Super User
Super User

Can you explain with an example

Timestamp can be converted into date like

 

Date = table[timestamp].date

Year- format(table[timestamp],"YYYY")

Month Year = format(table[timestamp].date,"MMM-YYYY")

Month Year sort= format(table[timestamp].date,"YYYYMM")

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you for your answers !

Here is an example :

TS colValues
2020/125
2020/114
2020/109
......
2019/126
2019/114
2019/102
......
2018/126
2018/117
2018/103

 

I want to print a graph to compare values with a line for each year.

 

Regards

 

 

Hi @Anonymous 

If your [TS col] column can be transformed to "date" type and format as below without any error,

Capture1.JPG

If not, please spilt your [TS col] column as @amitchandak  suggested, or you could split it in power query like the following:

Capture2.JPG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XcrJCQAgDATAXvYtmMS7Fkn/bWhQIfgcmDkhJBRZEFCg4Zm3szNtj2se51dn/8325bl/v5/fnO0nqC4=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"TS col" = _t, Values = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "TS col", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"TS col.1", "TS col.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"TS col.1", Int64.Type}, {"TS col.2", Int64.Type}, {"Values", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"TS col.1", "year"}, {"TS col.2", "month"}}),
    #"Inserted Merged Column" = Table.AddColumn(#"Renamed Columns", "date format", each Text.Combine({Text.Combine({Text.From([year], "en-US"), Text.From([month], "en-US")}, "/"),Text.From(1,"en-US")},"/"), type text),
    #"Changed Type1" = Table.TransformColumnTypes(#"Inserted Merged Column",{{"date format", type date}})
in
    #"Changed Type1"

Then close&&apply, create a date table, add columns to visuals as below

Capture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Prefer to convert it into date

date = Date(left([TS col],4),right([TS col],2),1)

and use time intelligence using date. Totalytd, datesytd etc

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"))
This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR('Date'[Date])),"12/31"))

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I find it really complicated just to split. But as i am a beginner, i guess that's the only way ?!

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.