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
ewelinag17
Frequent Visitor

DAX- A measure that count the cumulative percentage (Pareto-Lorenz chart)

Drogi,
potrzebuję pomocy. Chcę utworzyć wykres słupkowy (sumujący wartości w tabeli) i wykres liniowy (miara skumulowanego procenta) Pracuję na zbiorze danych „reklamacje”. Moja miara wygląda tak:

ewelinag17_0-1597174040495.png

 

Wykres jest poprawny, jeśli wartości na wykresie słupkowym nie powtarzają się.

ewelinag17_2-1597174124820.png

 


I odwrotnie, jeśli wartości są takie same, wykres przedstawia błędną analizę.

ewelinag17_1-1597174105900.png

 

Czego brakuje w mojej miarce?

Proszę o pomoc i z góry dziękuję za poświęcony czas.

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @ewelinag17 ,

You could try M code to create a new column

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQ0UNJRMlSK1QGyjZHYyOIWCLaxAZK4kSl29TjMRNFrTAQbyRwkppEpDquQnWNMwJmxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [pojemnosc = _t, Indeks.2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"pojemnosc", Int64.Type}, {"Indeks.2", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"pojemnosc"}, {{"Count", each Table.RowCount(_), type number}, {"all", each _, type table [pojemnosc=number, Indeks.2=number]}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Count", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1),
    #"Expanded all" = Table.ExpandTableColumn(#"Added Index", "all", {"pojemnosc", "Indeks.2"}, {"pojemnosc.1", "Indeks.2"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded all",{"Count", "pojemnosc.1"})
in
    #"Removed Columns"

 

 You could refer to my sample for details.

Best Regards,
Zoe Zhi

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

5 REPLIES 5
dax
Community Support
Community Support

Hi @ewelinag17 , 

It seems that you want to show distinct category in chart, right? If so and if possible could you please inform me more detailed information(such as your logic, expected output and your sample data )? Then I will help you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

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

@dax 

An example data table is shown below.

ewelinag17_0-1597266426383.png

I create a graph from the data.

ewelinag17_1-1597266575904.png

I create a line chart with measure:

pareto-l =
VAR TotalIndeks = CALCULATE(SUM('Table'[Indeks.2]),ALLSELECTED('Table'))
VAR CurrentIndeks = SUM('Table'[Indeks.2])
VAR SummarizedTable =
SUMMARIZE(
    ALLSELECTED('Table'),
    'Table'[pojemnosc],
    "Indeks.2",SUM('Table'[Indeks.2])
)
VAR CumulativeSum =
SUMX(
    FILTER(SummarizedTable,[Indeks.2] >= CurrentIndeks),
    [Indeks.2]
)
RETURN
DIVIDE(CumulativeSum,TotalIndeks)
The chart is good, but I need to calculate the cumulative percentage. 
190 - 33,3%
130 - 61.9%
125 - 76.2%
300 - 85,7%
180 - 90,4%
250 - 95,2%
90 - 100%
I guess a random variable is missing(rand??), but I'm new to Power BI and don't know how to do this.
Thank you in advance for your help.
 
dax
Community Support
Community Support

Hi @ewelinag17 ,

You could try M code to create a new column

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQ0UNJRMlSK1QGyjZHYyOIWCLaxAZK4kSl29TjMRNFrTAQbyRwkppEpDquQnWNMwJmxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [pojemnosc = _t, Indeks.2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"pojemnosc", Int64.Type}, {"Indeks.2", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"pojemnosc"}, {{"Count", each Table.RowCount(_), type number}, {"all", each _, type table [pojemnosc=number, Indeks.2=number]}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Count", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1),
    #"Expanded all" = Table.ExpandTableColumn(#"Added Index", "all", {"pojemnosc", "Indeks.2"}, {"pojemnosc.1", "Indeks.2"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded all",{"Count", "pojemnosc.1"})
in
    #"Removed Columns"

 

 You could refer to my sample for details.

Best Regards,
Zoe Zhi

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

@dax 

Great! But if I add a column and filter relative to the new column, the chart won't be stacked. 

That's enough for now, but in the future this file will grow by a few columns. And then how to filter on new columns?

dax
Community Support
Community Support

Hi @ewelinag17 , 

As I know, the slicer will affect on measure, it seem not affect on calculated column, so you need to use measure to achieve this goal.

Best Regards,
Zoe Zhi

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

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.

Top Solution Authors
Top Kudoed Authors