Forum Discussion
Anonymous
5 years agoNot applicable
Creating measure based on 2 statements
Hi, I'm having issues creating a measure that can filter vaules in 2 separate columns. I'm looking to calculate kidnapping rate for each type of alert. My original calculation doesn't seem to take in...
- 5 years ago
[# Alerts] = COUNTROWS( T ) // T being your table [Kidnapping Rate] = DIVIDE( CALCULATE( [# Alerts], KEEPFILTERS( // Names of columns should be // as short as possible but // still meaningful. T[Incidents with Crew Kidnapped] = "YES" ) ), [# Alerts] )I warn you against having one-table models and not following the star schema. Watch this: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Why-one-table-models-will-produce-WRONG-NUMBERS/td-p/1904161
daxer-almighty
5 years agoSolution Sage
[# Alerts] = COUNTROWS( T ) // T being your table
[Kidnapping Rate] =
DIVIDE(
CALCULATE(
[# Alerts],
KEEPFILTERS(
// Names of columns should be
// as short as possible but
// still meaningful.
T[Incidents with Crew Kidnapped] = "YES"
)
),
[# Alerts]
)I warn you against having one-table models and not following the star schema. Watch this: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Why-one-table-models-will-produce-WRONG-NUMBERS/td-p/1904161
Anonymous
5 years agoNot applicable
Thanks for your solution, it is very much appreciated. I shall take a look at the video to improve things.