Forum Discussion
Calculated column based on column from another table
- 5 years ago
Hi Anonymous
Most_recent = VAR actsInGrp_ = CALCULATETABLE ( DISTINCT ( History[ID_activity] ), ALLEXCEPT ( History, History[ID_Group] ) ) VAR current_ = CALCULATE ( MAX ( Activity[date] ), FILTER ( ALL ( Activity[ID_activity] ), Activity[ID_activity] = History[ID_activity] ) ) VAR maxInGrp_ = MAXX ( FILTER ( Activity, Activity[ID_activity] IN actsInGrp_ ), Activity[date] ) RETURN current_ = maxInGrp_This can also be done in Power query (probably better) and it can be simplified in DAX if you can create a relationship betweenthe two tables
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
- 5 years ago
Hi Anonymous ,
If there is such a relationship between activity table and history table, try the following DAX statement.
most_recent = VAR _date = RELATED ( activity[date] ) VAR recent = CALCULATE ( MAX ( activity[date] ), ALLEXCEPT ( history, history[ID_group] ) ) RETURN IF ( _date = recent, TRUE (), FALSE ()Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous
Most_recent =
VAR actsInGrp_ =
CALCULATETABLE (
DISTINCT ( History[ID_activity] ),
ALLEXCEPT ( History, History[ID_Group] )
)
VAR current_ =
CALCULATE (
MAX ( Activity[date] ),
FILTER (
ALL ( Activity[ID_activity] ),
Activity[ID_activity] = History[ID_activity]
)
)
VAR maxInGrp_ =
MAXX (
FILTER ( Activity, Activity[ID_activity] IN actsInGrp_ ),
Activity[date]
)
RETURN
current_ = maxInGrp_
This can also be done in Power query (probably better) and it can be simplified in DAX if you can create a relationship betweenthe two tables
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers