Forum Discussion
Assign different value
- 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.
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.
Hi Barthel
Thanks for the inputs I am trying your mentioned approach but got stuck while creating user and type column could you please help me on this.
Thank you