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

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.

Reply
crizbe
New Member

Line chart points from columns

I have the following SharePoint lists:

Plans:

PlanCurveDescription
Plan001Curve001 
Plan002Curve002 

 

Curves:

CurveValueAMeasureAValueBMeasureB
Curve0011010050100
Curve00220304080

 

A User can select a Plan. When it gets selected, I want to draw a lina chart of the corresponding curve, where the datapoints consist of Value (X-Axis) and Measure (Y-Axis).

 

I managed to get all the values with either measure column or calculation column. But I am not able to draw the chart. I think it is because each field in curve is also a column.

 

The chart works perfectly when I create a table like this from hand:

ValueMeasure
10100
50100

Is there any way to create such a table automatically when a Plan gets selected? Or do you know any other way how I could achieve this?

2 ACCEPTED SOLUTIONS

Here is one possible approach

 

lbendlin_0-1654477955113.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci4tKks1MDBU0lEyNAATINIUxozVgSsxAgoZgcSNQYQJiLAAKogFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Curve = _t, ValueA = _t, MeasureA = _t, ValueB = _t, MeasureB = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Curve", type text}, {"ValueA", Int64.Type}, {"MeasureA", Int64.Type}, {"ValueB", Int64.Type}, {"MeasureB", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "List", each {{[ValueA],[MeasureA]},{[ValueB],[MeasureB]}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Curve", "List"}),
    #"Expanded List" = Table.ExpandListColumn(#"Removed Other Columns", "List"),
    #"Extracted Values" = Table.TransformColumns(#"Expanded List", {"List", each Text.Combine(List.Transform(_, Text.From), "#(tab)"), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "List", Splitter.SplitTextByDelimiter("#(tab)", QuoteStyle.Csv), {"x", "y"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"x", Int64.Type}, {"y", Int64.Type}})
in
    #"Changed Type1"

 

 

View solution in original post

Hi @crizbe ,

 

I think you can create a relationship between Plan table and Curve table by [Curve] column.

For reference: Create and manage relationships in Power BI Desktop

RicoZhou_0-1654591801283.png

Then you can create a slicer by [Plan] column from Plan table. 

By default:

RicoZhou_1-1654591867645.png

Select Plan001:

RicoZhou_2-1654591892320.png

Select Plan002:

RicoZhou_3-1654591903170.png

 

Best Regards,
Rico Zhou

 

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

7 REPLIES 7
lbendlin
Super User
Super User

Yes, usually you would need to unpivot your Curves table  - in this case in pairs.

 

What's the importance of "A" and "B" - does that play any role later?

Thanks, yes A and B are the X and Y Values of each point in the chart

Hi @crizbe ,

 

I agree with lbendlin's reply. Due to we cannot see calculated column or measure created by Dax in Power Query Editor, firstly, you need to calcualte MeasureA and MeasureB by M code in Power Query Editor. Then you can follow  lbendlin's step to unpivot your table. 

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Here is one possible approach

 

lbendlin_0-1654477955113.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci4tKks1MDBU0lEyNAATINIUxozVgSsxAgoZgcSNQYQJiLAAKogFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Curve = _t, ValueA = _t, MeasureA = _t, ValueB = _t, MeasureB = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Curve", type text}, {"ValueA", Int64.Type}, {"MeasureA", Int64.Type}, {"ValueB", Int64.Type}, {"MeasureB", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "List", each {{[ValueA],[MeasureA]},{[ValueB],[MeasureB]}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Curve", "List"}),
    #"Expanded List" = Table.ExpandListColumn(#"Removed Other Columns", "List"),
    #"Extracted Values" = Table.TransformColumns(#"Expanded List", {"List", each Text.Combine(List.Transform(_, Text.From), "#(tab)"), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "List", Splitter.SplitTextByDelimiter("#(tab)", QuoteStyle.Csv), {"x", "y"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"x", Int64.Type}, {"y", Int64.Type}})
in
    #"Changed Type1"

 

 

Thank you very much. It worked like a charm! I have one slight issue now. How am I able to filter the values now based on selectedValues?

Hi @crizbe ,

 

I think you can create a relationship between Plan table and Curve table by [Curve] column.

For reference: Create and manage relationships in Power BI Desktop

RicoZhou_0-1654591801283.png

Then you can create a slicer by [Plan] column from Plan table. 

By default:

RicoZhou_1-1654591867645.png

Select Plan001:

RicoZhou_2-1654591892320.png

Select Plan002:

RicoZhou_3-1654591903170.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you so much! It works as expected now.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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