Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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:
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:
Is it possible that I can achieve this in Power BI?
Thanks for the help!
Solved! Go to Solution.
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
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
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @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
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
Proud to be a Super User!
Check out my blog: Power BI em Português@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])) )
User | Count |
---|---|
73 | |
70 | |
38 | |
25 | |
23 |
User | Count |
---|---|
96 | |
93 | |
50 | |
43 | |
42 |