Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Assign different value

Hi All,   Can some one please help me with the below scenario. when user selects a value from filter it should display that user name and rest all should be displayed B1, B2 .... Below is the sam...
  • Barthel's avatar
    4 years ago

    Hey,

     

    Good point! It should also be possible with a disconnected table.

    Create a table with all unique users. Create a table with b variants; the same number as the number of users. Append these tables together, so you get a table like this:

    Then add two columns: one column (‘User’) in which the username is always shown and one column (‘Type’) to distinguish between username and b variant. In this case I use 'U' for username and 'B' for variant:

     

    Place the 'Value' column in a matrix and place the username column from your original table (so not the disconnected one) in a slicer. The next step is to create the right measure. Use this code for your measure:

    Measure = 
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( DiscUsers[Type] ) = "U",
            CALCULATE (
                SUM ( 'Table'[Amount] ),
                KEEPFILTERS ( TREATAS ( VALUES ( DiscUsers[User] ), 'Table'[User] ) )
            ),
        SELECTEDVALUE ( DiscUsers[User] ) <> SELECTEDVALUE ( 'Table'[User] ),
            CALCULATE (
                SUM ( 'Table'[Amount] ),
                TREATAS ( VALUES ( DiscUsers[User] ), 'Table'[User] )
            )
    )

    Also in this case the B does not always start at 1. It is possible to realize this, but that would make the code more complex and that may not be ideal with real time data.