Forum Discussion
Anonymous
7 years agoNot applicable
Create a calculated column based on another value in the same table
Hello. I have a table with 3 columns (SessionID, UserID, UsedFeature) and I want to create a calculated column with a flag that is 0 if a user has never used the feature in all of his sessions, 1...
- 7 years ago
Hi Anonymous ,
Try this:
NewColumn = VAR Num_Yes_ = CALCULATE ( COUNT ( Table1[UsedFeature] ), ALLEXCEPT ( Table1, Table1[UserID] ), Table1[UsedFeature] = "Yes" ) VAR Num_No_ = CALCULATE ( COUNT ( Table1[UsedFeature] ), ALLEXCEPT ( Table1, Table1[UserID] ), Table1[UsedFeature] = "No" ) VAR Num_Total_ = Num_Yes_ + Num_No_ RETURN SWITCH ( Num_Total_, Num_No_, 0, Num_Yes_, 1, 2 )
AlB
Community Champion
7 years agoHi Anonymous ,
Try this:
NewColumn =
VAR Num_Yes_ =
CALCULATE (
COUNT ( Table1[UsedFeature] ),
ALLEXCEPT ( Table1, Table1[UserID] ),
Table1[UsedFeature] = "Yes"
)
VAR Num_No_ =
CALCULATE (
COUNT ( Table1[UsedFeature] ),
ALLEXCEPT ( Table1, Table1[UserID] ),
Table1[UsedFeature] = "No"
)
VAR Num_Total_ = Num_Yes_ + Num_No_
RETURN
SWITCH ( Num_Total_, Num_No_, 0, Num_Yes_, 1, 2 )