Forum Discussion

trine_norris's avatar
trine_norris
Frequent Visitor
6 years ago

Optimizing the allexcept function

Hi, 

 

I have some data (Record ID and Key) and two measures (Selected and Max), which currently looks something like this:

 

Record IDKeySelectedMax
1uniquekey1 0,67
1uniquekey2 0,67
1uniquekey30,670,67
1uniquekey40,420,67
1uniquekey5 0,67
1uniquekey6 0,67
1uniquekey7 0,67
1uniquekey8 0,67
1uniquekey9 0,67
1uniquekey100,340,67
1uniquekey11 0,67
1uniquekey12 0,67
1uniquekey13 0,67
2uniquekey1 0,45
2uniquekey2 0,45
2uniquekey30,330,45
2uniquekey40,450,45
2uniquekey5 0,45
2uniquekey6 0,45
2uniquekey7 0,45
2uniquekey8 0,45
2uniquekey9 0,45
2uniquekey100,340,45
2uniquekey11 0,45
2uniquekey12 0,45
2uniquekey13 0,45

 

"Selected" currently highlights a value of the Key's that are actively selected. 

Instead "Max" finds the maximum "Selected" value, grouped by Record ID's. It is defined like this:

 

Max = calculate([Selected]; ALLEXCEPT(Table, Table[Record ID]))

 

This solution works - however it is a major problem, that this max function does not ignore the rows without any Selected value. This is because the data set is about one billion rows long. Is there any way to get this functionality without including the deselected Keys?

Thanks in advance!

 

 

 

 

11 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion
    Perhaps:
    Max =
    VAR __Max = calculate([Selected]; ALLEXCEPT(Table, Table[Record ID]))
    RETURN IF(ISBLANK([Selected]),BLANK(),__Max)
    • trine_norris's avatar
      trine_norris
      Frequent Visitor

      It now returns the right thing, but is not really quicker, as it still calculates on all rows in the variabel.

       

      I was thinking that something like:

      Max = Calculate(Selected, distinct(Record ID))

      should work, but of course that syntax is invalid.

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion
        OK, try this, this should be faster:
        Max =
        IF(ISBLANK([Selected]);BLANK();
        calculate([Selected]; ALLEXCEPT(Table, Table[Record ID])))
  • Anonymous's avatar
    Anonymous
    Not applicable
    Can you please show me your [Selected] measure?

    I suspect you are talking about calculated columns here, not measures.

    Best
    D
    • trine_norris's avatar
      trine_norris
      Frequent Visitor

      Hi Darlove, 

       

      There are no calculated columns in my example, even though it is displayed like it.

       

      My selected measure looks something like this:

       

      Selected = calculate( max( Table[Value] ),
                        filter( Table[Key] in Union(

                        values(Table1[Key]), 

                        values(Table2[Key]),

                        values(Table3[Key])....

      )))

       

      So basically i have many slicers selecting which rows should be active. As it is a big dataset, one slicer cannot make all the selections, and still make sense for the use. So I cannot make an active relationship in the Data Model.

       

      • trine_norris's avatar
        trine_norris
        Frequent Visitor

        To elaborate, i have many tables in which the user can select slicers to define which row should be active. So each table returns one row or one key based on the slicer selection. These are then highlighted by Selected.