Forum Discussion
MartinAa
3 years agoFrequent Visitor
Create a new column with DAX
Hi all , I am stuck with an issue for quiet sometime and unable to figure it out . I am tryinng to create a new column by totally using four columns from my table using DAX . So the need is. If ...
- 3 years ago
NewColumn = VAR _tbl = FILTER ( 'Sample', 'Sample'[PersonID] = EARLIER ( 'Sample'[PersonID] ) && 'Sample'[Month] = EARLIER ( 'Sample'[Month] ) ) RETURN IF ( COUNTROWS ( SUMMARIZE ( _tbl, 'Sample'[ProjectID] ) ) > 1, SUMX ( _tbl, 'Sample'[PercentageAllocated] ), AVERAGEX ( _tbl, 'Sample'[PercentageAllocated] ) ) - 3 years ago
NewColumn = VAR _tbl = FILTER ( 'Sample', 'Sample'[PersonID] = EARLIER ( 'Sample'[PersonID] ) && 'Sample'[Month] = EARLIER ( 'Sample'[Month] ) ) VAR _Projects = SUMMARIZE ( _tbl, 'Sample'[ProjectID] ) RETURN IF ( COUNTROWS ( _Projects ) > 1, SUMX ( _Projects, AVERAGEX(FILTER(_tbl,'Sample'[ProjectID]=EARLIER('Sample'[ProjectID])),'Sample'[PercentageAllocated] )), AVERAGEX ( _tbl, 'Sample'[PercentageAllocated] ) )
MartinAa
3 years agoFrequent Visitor
Works perfectly fine .
Accepted as the solution..!!
Thanks wdx223_Daniel . 😀
wdx223_Daniel
3 years agoCommunity Champion
NewColumn
=
VAR _tbl =
FILTER (
'Sample',
'Sample'[PersonID] = EARLIER ( 'Sample'[PersonID] )
&& 'Sample'[Month] = EARLIER ( 'Sample'[Month] )
)
VAR _Projects = SUMMARIZE ( _tbl, 'Sample'[ProjectID] )
RETURN
IF (
COUNTROWS ( _Projects ) > 1,
SUMX ( _Projects, AVERAGEX(FILTER(_tbl,'Sample'[ProjectID]=EARLIER('Sample'[ProjectID])),'Sample'[PercentageAllocated] )),
AVERAGEX ( _tbl, 'Sample'[PercentageAllocated] )
)- MartinAa3 years agoFrequent Visitor
wdx223_Daniel - You Beauty ..!! 😃
You just taught me soo much with the above DAX... !!
Thank you soo much for the timely response.. Works perfect..!!
Will over-ride the previous solution with the current one as the solution. Thanks wdx223_Daniel ..!!