Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Override Slicer for 1 Column in Matrix

Hello,

I've tried to google/search the subject of this post - haven't found what I'm looking for.

If I missed it and someone has a link, please share!

I have a slicer at the top of my page:

I want the slicer to act on every column in my matrix except one:

LocationNumber1Oct20Number2Oct20Number3Oct20Number3Apr21
North 14-3-2 
South23-0.5-0.50 
East12-1.30-1.10 
West8-0.090.00 

 

Number3Apr - is supposed to be the furthest "future" number we have available in the system.

Without the Slicer on the page, I would have written a Dax Measure as follows:

Calculate (sum (Table1[Number3]), Filter(Table1, Table1[Date] = Max (Table1[Date])))

 

This almost gets me there:

Calculate(

                Sum (Table1[Number3]), 

                All (Table1),

                Filter(Table1, Table1[Date] = Max (Table1[Date]))
                )

But it takes away the Row Context (ie same number for every location).

Is there any way to write it and get the Location Context?

 

Appreciate any help or advice. TYIA.

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous 

    Try this code.

    Number3 Apr21 =
    VAR _MaxDate =
        MAXX (
            FILTER ( ALL ( Table1 ), Table1[Location] = MAX ( Table1[Location] ) ),
            Table1[Date]
        )
    RETURN
        CALCULATE (
            SUM ( Table1[Number3] ),
            FILTER (
                ALL ( Table1 ),
                AND ( Table1[Date] = _MaxDate, Table1[Location] = MAX ( Table1[Location] ) )
            )
        )

    My Sample looks like below.

    Result is as below.

     

    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.

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous Try ALLEXCEPT(Table1,Table1[Location])

    • Anonymous's avatar
      Anonymous
      Not applicable

      Calculate(

                      Sum (Table1[Number3]), 

                      AllExcept (Table1,Table1[Location]),

                      Filter(Table1, Table1[Date] = Max (Table1[Date]))
                      )

      Result did not change, still no row context.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Calculate(

                    Sum (Table1[Number3]), 

                    Filter( AllExcept (Table1,Table1[Location]), Table1[Date] = Max (Table1[Date]))
                    )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous Sorry, these don't work. same number for every location.

       

  • Anonymous not sure if I understood what you are trying to achieve. It will be easier if you share pbix file with the expected output and let's go from there. Remove sensitive information before sharing. You can share using onedrive/google drive

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    Try this code.

    Number3 Apr21 =
    VAR _MaxDate =
        MAXX (
            FILTER ( ALL ( Table1 ), Table1[Location] = MAX ( Table1[Location] ) ),
            Table1[Date]
        )
    RETURN
        CALCULATE (
            SUM ( Table1[Number3] ),
            FILTER (
                ALL ( Table1 ),
                AND ( Table1[Date] = _MaxDate, Table1[Location] = MAX ( Table1[Location] ) )
            )
        )

    My Sample looks like below.

    Result is as below.

     

    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.