Forum Discussion
mohanpal
4 years agoFrequent Visitor
How to divide values from Same column based on filter
Hi, I have this sample data. I want to create a column 'Percentage' which should divide based on ID and Year. I did manage to write a query but that is aggreating all the projection value and g...
- 4 years ago
Hi mohanpal
If you accept a DAX method, you can create a calculated column with below DAX. This will add a new column to the table.
Percentage = VAR _projectionA = MAXX ( FILTER ( 'Table', 'Table'[Id] = EARLIER ( 'Table'[Id] ) && 'Table'[Year] = EARLIER ( 'Table'[Year] ) && 'Table'[Label] = "A" ), 'Table'[Projection] ) VAR _projectionB = MAXX ( FILTER ( 'Table', 'Table'[Id] = EARLIER ( 'Table'[Id] ) && 'Table'[Year] = EARLIER ( 'Table'[Year] ) && 'Table'[Label] = "B" ), 'Table'[Projection] ) RETURN DIVIDE ( _projectionA, _projectionB )----------------------------------------------------------------------
If this reply helps solve the problem, please mark it as Solution! Kudos are appreciated too!
liuqi_pbi
4 years agoResolver III
Hi mohanpal
If you accept a DAX method, you can create a calculated column with below DAX. This will add a new column to the table.
Percentage =
VAR _projectionA =
MAXX (
FILTER (
'Table',
'Table'[Id] = EARLIER ( 'Table'[Id] )
&& 'Table'[Year] = EARLIER ( 'Table'[Year] )
&& 'Table'[Label] = "A"
),
'Table'[Projection]
)
VAR _projectionB =
MAXX (
FILTER (
'Table',
'Table'[Id] = EARLIER ( 'Table'[Id] )
&& 'Table'[Year] = EARLIER ( 'Table'[Year] )
&& 'Table'[Label] = "B"
),
'Table'[Projection]
)
RETURN
DIVIDE ( _projectionA, _projectionB )
----------------------------------------------------------------------
If this reply helps solve the problem, please mark it as Solution! Kudos are appreciated too!