Reputation: 95
I would like to create a measure that will fill the whole Column within the filter context using only the value from SALES column where PRIMARY = true
That needs to be happening within the filter context and the report will be filtered by KEY column, that comes from another table and also by Year and Month that comes from the time table.
KEY | NAME | PRIMARY | SALES | MEASURE |
---|---|---|---|---|
1 | A | true | 10 | 10 |
1 | B | false | 2 | 10 |
1 | C | false | 3 | 10 |
2 | D | false | 15 | 80 |
2 | E | false | 5 | 80 |
2 | F | true | 80 | 80 |
Could anyone translate these requirements to DAX?
Upvotes: 1
Views: 3107
Reputation: 1791
Assuming that your column PRIMARY
is type boolean
you can use the following calculated column.
MEASURE =
VAR SelectedSales = [SALES]
VAR SelectedKey = [KEY]
VAR GetSelectedSales =
MAXX ( FILTER ( 'Table', [PRIMARY] = TRUE () && [KEY] = SelectedKey ), [SALES] )
RETURN
IF ( [PRIMARY], [SALES], GetSelectedSales )
KEY | NAME | PRIMARY | SALES | MEASURE |
---|---|---|---|---|
1 | A | True | 10 | 10 |
1 | B | False | 2 | 10 |
1 | C | False | 3 | 10 |
2 | D | False | 15 | 80 |
2 | E | False | 5 | 80 |
2 | F | True | 80 | 80 |
Upvotes: 1