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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
liuy70
New Member

Plotting line chart with time-series data, time values in column names

I am tring to plot a line chart to display the trend of average daily usage of our website for each user. The data format looks like following: Screenshot 2024-05-06 092508.png

Each row is a user and I need to first calculate the average daily duration for each day (01/08, 01/09, etc.) and then plot each average to a line chart. 

The plot I am trying to replicate looks like this:

liuy70_0-1715003292101.png

 

 Is it possible that I can achieve this in Power BI?

 

Thanks for the help!

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @liuy70,

 

You need to unpivot your columns and convert it to dates so you can have a way of doing the correct formatting.

Start by selecting all the columns except the daily values and then do a unpivot other columns you will get two columns Attribute and Values. Change the attribute values so you only get the dates and then you can use them on a visual

MFelix_0-1715007094066.png

MFelix_1-1715007116448.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcgsytLQ0NrBU0lFKBGJXIPZ1DwFR/iUZqUVA2tAARJgCCSMDpVgdkBYjAwOIliQgDgZiZw9XX0JaDCFakmFagp09cWqJBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Cohort = _t, RIN = _t, College = _t, Major1 = _t, #"COhort COde" = _t, #"Daily_Duration_01/08" = _t, #"Daily_Duration_01/09" = _t, #"Daily_Duration_01/10" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Cohort", "RIN", "College", "Major1", "COhort COde"}, "Attribute", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Other Columns","Daily_Duration_","",Replacer.ReplaceText,{"Attribute"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Attribute", type date}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Attribute", "Date"}})
in
    #"Renamed Columns"

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @liuy70,

 

You need to unpivot your columns and convert it to dates so you can have a way of doing the correct formatting.

Start by selecting all the columns except the daily values and then do a unpivot other columns you will get two columns Attribute and Values. Change the attribute values so you only get the dates and then you can use them on a visual

MFelix_0-1715007094066.png

MFelix_1-1715007116448.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcgsytLQ0NrBU0lFKBGJXIPZ1DwFR/iUZqUVA2tAARJgCCSMDpVgdkBYjAwOIliQgDgZiZw9XX0JaDCFakmFagp09cWqJBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Cohort = _t, RIN = _t, College = _t, Major1 = _t, #"COhort COde" = _t, #"Daily_Duration_01/08" = _t, #"Daily_Duration_01/09" = _t, #"Daily_Duration_01/10" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Cohort", "RIN", "College", "Major1", "COhort COde"}, "Attribute", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Other Columns","Daily_Duration_","",Replacer.ReplaceText,{"Attribute"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Attribute", type date}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Attribute", "Date"}})
in
    #"Renamed Columns"

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



amitchandak
Super User
Super User

@liuy70  , Assume need Avg of all users on a daily basis. if the trend is on date

 

Averagex(Values(Table[USer]), calculate(Sum(Table[daily usage])) )

 

If user is on axis

 

Averagex(Values(Table[Date]), calculate(Sum(Table[daily usage])) )

 

 

 

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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