Forum Discussion
AllanBerces
1 year agoPost Prodigy
Combine Column
Hi good day, pls can anyone help me on my table how can i get the result i required. DESIRED OUTPUT Thank you
- 1 year ago
Hi AllanBerces
While this is very possible in DAX, the calculation won't update with new columns as each column has to be manually referenced and if a colum that's been referenced is deleted, the calc table will return an error.
UnpivotDAX = VAR _job = DISTINCT ( SourceTable[Job] ) VAR _jobyr = CROSSJOIN ( _job, SELECTCOLUMNS ( { 2024, 2025 }, "Year", [Value] ) ) VAR _earned = ADDCOLUMNS ( _jobyr, "Earned", VAR _job = [Job] VAR _2024 = SUMX ( FILTER ( SourceTable, [Job] = _job ), [Earned_2024] ) VAR _2025 = SUMX ( FILTER ( SourceTable, [Job] = _job ), [Earned_2025] ) RETURN SWITCH ( [Year], 2024, _2024, 2025, _2025 ) ) RETURN FILTER ( _earned, NOT ( ISBLANK ( [Earned] ) ) )
danextian
1 year agoSuper User
Hi AllanBerces
While this is very possible in DAX, the calculation won't update with new columns as each column has to be manually referenced and if a colum that's been referenced is deleted, the calc table will return an error.
UnpivotDAX =
VAR _job =
DISTINCT ( SourceTable[Job] )
VAR _jobyr =
CROSSJOIN ( _job, SELECTCOLUMNS ( { 2024, 2025 }, "Year", [Value] ) )
VAR _earned =
ADDCOLUMNS (
_jobyr,
"Earned",
VAR _job = [Job]
VAR _2024 =
SUMX ( FILTER ( SourceTable, [Job] = _job ), [Earned_2024] )
VAR _2025 =
SUMX ( FILTER ( SourceTable, [Job] = _job ), [Earned_2025] )
RETURN
SWITCH ( [Year], 2024, _2024, 2025, _2025 )
)
RETURN
FILTER ( _earned, NOT ( ISBLANK ( [Earned] ) ) )
- AllanBerces1 year agoPost Prodigy
Hi danextian thank you very much for the reply, very much appreciated. work as i need.