Forum Discussion
Foguete
3 years agoHelper I
Addcolumn, different cases, summarize
Hello, I need help as I am trying to build a table with a case I never face untill now. I currently have a table with different line that I want to summarize. For example: date task ce...
FreemanZ
3 years agoSuper User
hi Foguete
try to create a calculated table like:
Table =
VAR _table=
ADDCOLUMNS(
SUMMARIZE(
TableName,
TableName[Date],
TableName[task]
),
"center", "c",
"Qty", CALCULATE(SUM(TableName[Qty]))
)
RETURN
UNION(TableName, _table)
verified and worked like this:
- FreemanZ3 years agoSuper User
hi Foguete
if you mind the column ordering, try this:
Table = VAR _table= ADDCOLUMNS( SUMMARIZE( TableName, TableName[Date], TableName[task] ), "center", "c", "Qty", CALCULATE(SUM(TableName[Qty])) ) VAR _table2= UNION(TableName, _table) RETURN SELECTCOLUMNS( _table2, "date", TableName[date], "center", TableName[center], "task", TableName[task], "qty", TableName[qty] ) - Foguete3 years agoHelper I
Thank you FreemanZ , however I have been simplifying "TableName" and in reality it has more column. So on, UNION is throwing the error "it must have the same number of columns".
How can I get through that ?
- FreemanZ3 years agoSuper User
hi Foguete
i am afraid there might be no easy workaround. How many column do you have?
- Foguete3 years agoHelper I
Hi FreemanZ,
Thanks for the DAX, a slight modification and I have found the solution.
Here in red, it is in case someone would get there:
UNION(SELECTCOLUMNS(TableName,"date", TableName[date],"task", TableName[task],"center", TableName[center],"qty", TableName[qty]),_table)