Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Max and Min per Category Calculation Problem

Hello world, 

I have a huge list of suppliers that each of them has a specific priority. 
I want in case of same supplier - different priority to highlight the name of supplier. 
My idea was something like 

 

 

Max measure = 
    CALCULATE (
        MAX ( ' Suppliers'[Priority] ),
        ALLEXCEPT ( 'Suppliers','Suppliers'[Supplier Name] )
    )
Min measure = 
    CALCULATE (
        Min ( 'Suppliers'[Priority] ),
        ALLEXCEPT ( 'Suppliers','Suppliers'[Supplier Name] )
    )

 

 

and then compare the min and max measure, but it says that there's too much data and the visualization has exceeded the available resources. Any idea for this? I attach you a sample table of a single supplier.

Supl NameCod1Code 2DateType Priority
GER216100012/31/2011 0:00RAND SUPPLIER98
GER217100012/31/2011 0:00RAND SUPPLIER98
GER218100012/31/2011 0:00RAND SUPPLIER99
GER219100012/31/2011 0:00RAND SUPPLIER99
GER220100012/31/2011 0:00RAND SUPPLIER99
GER221100012/31/2011 0:00RAND SUPPLIER99
GER222100012/31/2011 0:00RAND SUPPLIER99
GER223100012/31/2011 0:00RAND SUPPLIER99
GER224100012/31/2011 0:00RAND SUPPLIER99
GER225100012/31/2011 0:00RAND SUPPLIER99
GER226100012/31/2011 0:00RAND SUPPLIER99
GER227100012/31/2011 0:00RAND SUPPLIER99
GER228100012/31/2011 0:00RAND SUPPLIER99
GER229100012/31/2011 0:00RAND SUPPLIER99
GER230100012/31/2011 0:00RAND SUPPLIER99

Thank you in advance world.!

  • BA_Pete's avatar
    BA_Pete
    6 years ago

    Anonymous 

     

    OK, so you have the output format you want, it's just the measures are overloading the resource limit, right?

    Maybe try adding the Min/Max into the table in Power Query beforehand, something like this:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("pdK7CoAwDIXhV5HOgknqpXUTFBFESsWp+P6v4WWRjvEsCYR825+SmadoSiPc3pOJ6FlSWa6EmAvq30sctrHYjxDW5X33zpzlZzvAOpX1mfX/rRBgGbACWAvYGrANYHVd5VbXVW6BrgToyqq7Oi8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Supl Name" = _t, Cod1 = _t, #"Code 2" = _t, Date = _t, #"Type " = _t, Priority = _t]),
        groupSupplier = Table.Group(Source, {"Supl Name"}, {{"data", each _, type table [Supl Name=text, Cod1=number, Code 2=number, Date=text, #"Type "=text, Priority=number]}}),
        addMinPrio = Table.AddColumn(groupSupplier, "minPriority", each Table.Min([data], "Priority")),
        addMaxPrio = Table.AddColumn(addMinPrio, "maxPriority", each Table.Max([data], "Priority")),
        expandMinPrio = Table.ExpandRecordColumn(addMaxPrio, "minPriority", {"Priority"}, {"minPriority"}),
        expandMaxPrio = Table.ExpandRecordColumn(expandMinPrio, "maxPriority", {"Priority"}, {"maxPriority"}),
        expandData = Table.ExpandTableColumn(expandMaxPrio, "data", {"Cod1", "Code 2", "Date", "Type ", "Priority"}, {"Cod1", "Code 2", "Date", "Type ", "Priority"}),
        chgDateLocaleUS = Table.TransformColumnTypes(expandData, {{"Date", type datetime}}, "en-US"),
        chgAllDataTypes = Table.TransformColumnTypes(chgDateLocaleUS,{{"Cod1", type text}, {"Code 2", type text}, {"Date", type date}, {"Priority", type number}, {"minPriority", type number}, {"maxPriority", type number}})
    in
        chgAllDataTypes

     

    I'm thinking this may take some of the calculational load off?

     

    Pete

8 Replies

  • Hi Anonymous 

     

    Can you provide an example of what your desired output looks like please?

     

    Pete

  • Anonymous , During the display of visual can you reduce the number of columns. Also, try to have only on pbix open

    Is this min-max  static or changes based on filter

      • BA_Pete's avatar
        BA_Pete
        Icon for Super User rankSuper User

        Anonymous 

         

        OK, so you have the output format you want, it's just the measures are overloading the resource limit, right?

        Maybe try adding the Min/Max into the table in Power Query beforehand, something like this:

        let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("pdK7CoAwDIXhV5HOgknqpXUTFBFESsWp+P6v4WWRjvEsCYR825+SmadoSiPc3pOJ6FlSWa6EmAvq30sctrHYjxDW5X33zpzlZzvAOpX1mfX/rRBgGbACWAvYGrANYHVd5VbXVW6BrgToyqq7Oi8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Supl Name" = _t, Cod1 = _t, #"Code 2" = _t, Date = _t, #"Type " = _t, Priority = _t]),
            groupSupplier = Table.Group(Source, {"Supl Name"}, {{"data", each _, type table [Supl Name=text, Cod1=number, Code 2=number, Date=text, #"Type "=text, Priority=number]}}),
            addMinPrio = Table.AddColumn(groupSupplier, "minPriority", each Table.Min([data], "Priority")),
            addMaxPrio = Table.AddColumn(addMinPrio, "maxPriority", each Table.Max([data], "Priority")),
            expandMinPrio = Table.ExpandRecordColumn(addMaxPrio, "minPriority", {"Priority"}, {"minPriority"}),
            expandMaxPrio = Table.ExpandRecordColumn(expandMinPrio, "maxPriority", {"Priority"}, {"maxPriority"}),
            expandData = Table.ExpandTableColumn(expandMaxPrio, "data", {"Cod1", "Code 2", "Date", "Type ", "Priority"}, {"Cod1", "Code 2", "Date", "Type ", "Priority"}),
            chgDateLocaleUS = Table.TransformColumnTypes(expandData, {{"Date", type datetime}}, "en-US"),
            chgAllDataTypes = Table.TransformColumnTypes(chgDateLocaleUS,{{"Cod1", type text}, {"Code 2", type text}, {"Date", type date}, {"Priority", type number}, {"minPriority", type number}, {"maxPriority", type number}})
        in
            chgAllDataTypes

         

        I'm thinking this may take some of the calculational load off?

         

        Pete