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.
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
Solved! Go to Solution.
Hi @Anonymous
If your [TS col] column can be transformed to "date" type and format as below without any error,
If not, please spilt your [TS col] column as @amitchandak suggested, or you could split it in power query like the following:
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
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.
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
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.
Thank you for your answers !
Here is an example :
TS col | Values |
2020/12 | 5 |
2020/11 | 4 |
2020/10 | 9 |
... | ... |
2019/12 | 6 |
2019/11 | 4 |
2019/10 | 2 |
... | ... |
2018/12 | 6 |
2018/11 | 7 |
2018/10 | 3 |
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,
If not, please spilt your [TS col] column as @amitchandak suggested, or you could split it in power query like the following:
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
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.
I find it really complicated just to split. But as i am a beginner, i guess that's the only way ?!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |