Forum Discussion
Semi Additive measure problem with multiple variables
- 2 years ago
Alright, I get what you're trying to achieve. You want to get the latest value for each combination of User, Doc, and Sensitive Type, and then sum those up based on different scenarios. Let's break this down.
First, you'll need to create a measure that identifies the latest date for each combination of User, Doc, and Sensitive Type. You can use the MAXX function to do this.
Latest Date =
MAXX(
FILTER(
ALL('fact'),
'fact'[User] = EARLIER('fact'[User]) &&
'fact'[Doc] = EARLIER('fact'[Doc]) &&
'fact'[Sensitive Type] = EARLIER('fact'[Sensitive Type])
),
'fact'[Date]
)
Once you have the latest date, you can create a measure to get the Count for that latest date:Latest Count =
CALCULATE(
SUM('fact'[Count]),
FILTER(
ALL('fact'),
'fact'[User] = EARLIER('fact'[User]) &&
'fact'[Doc] = EARLIER('fact'[Doc]) &&
'fact'[Sensitive Type] = EARLIER('fact'[Sensitive Type]) &&
'fact'[Date] = [Latest Date]
)
)
Now, you can use this Latest Count measure to sum up based on different scenarios:Total by Sensitive: Just drag the Sensitive Type column to a table visual and then add the Latest Count measure. It will automatically sum up the latest counts for each sensitive type.
Total by User: Similarly, drag the User column to a table visual and then add the Latest Count measure. It will sum up the latest counts for each user.
Total by Document: You can do the same thing with the Doc column.
For the date scenario, you can drag the Date column to a table visual and then add the Latest Count measure. It will show the latest count for each date, but when you sum them up, it will still be 27 as you mentioned.
Alright, I get what you're trying to achieve. You want to get the latest value for each combination of User, Doc, and Sensitive Type, and then sum those up based on different scenarios. Let's break this down.
First, you'll need to create a measure that identifies the latest date for each combination of User, Doc, and Sensitive Type. You can use the MAXX function to do this.
Latest Date =
MAXX(
FILTER(
ALL('fact'),
'fact'[User] = EARLIER('fact'[User]) &&
'fact'[Doc] = EARLIER('fact'[Doc]) &&
'fact'[Sensitive Type] = EARLIER('fact'[Sensitive Type])
),
'fact'[Date]
)
Once you have the latest date, you can create a measure to get the Count for that latest date:
Latest Count =
CALCULATE(
SUM('fact'[Count]),
FILTER(
ALL('fact'),
'fact'[User] = EARLIER('fact'[User]) &&
'fact'[Doc] = EARLIER('fact'[Doc]) &&
'fact'[Sensitive Type] = EARLIER('fact'[Sensitive Type]) &&
'fact'[Date] = [Latest Date]
)
)
Now, you can use this Latest Count measure to sum up based on different scenarios:
Total by Sensitive: Just drag the Sensitive Type column to a table visual and then add the Latest Count measure. It will automatically sum up the latest counts for each sensitive type.
Total by User: Similarly, drag the User column to a table visual and then add the Latest Count measure. It will sum up the latest counts for each user.
Total by Document: You can do the same thing with the Doc column.
For the date scenario, you can drag the Date column to a table visual and then add the Latest Count measure. It will show the latest count for each date, but when you sum them up, it will still be 27 as you mentioned.