Forum Discussion
ChoiJunghoon
Helper III
5 years agoCreate the new table with DAX considering Space.
Hello. Can Dax create the below the table ? TableA SpaceNumber 3 TableB Category SpaceNumber Cycle A 1 5 B 2 5 C 3 4 D 1 4 E 2 3 F 3 4 G 1 4...
- 5 years ago
Not DAX, but yes to power query.
load table B to PQadd a new column that creates a a list from 1 to the value in number cycle. It would look something like this.
={1..[NumberCycle]}
this will give a column containing lists. You should be able to expand this column into new rows.
- Anonymous5 years ago
define table TableB = DATATABLE( "Category", STRING, "SpaceNumber", INTEGER, "Cycle", INTEGER, { {"A", 1, 5}, {"B", 2, 4}, {"C", 3, 4}, {"D", 1, 4}, {"E", 2, 3}, {"F", 3, 4}, {"G", 1, 4}, {"H", 2, 5}, {"I", 3, 3} } ) EVALUATE SELECTCOLUMNS( GENERATE( TableB, var Cycle_ = TableB[Cycle] var SpaceNumber_ = TableB[SpaceNumber] var Category_ = TableB[Category] var CycleIndexStart = 1 + SUMX( filter( TableB, TableB[SpaceNumber] = SpaceNumber_ && TableB[Category] < Category_ ), TableB[Cycle] ) var CycleIndex_ = GENERATESERIES( CycleIndexStart, CycleIndexStart + Cycle_ - 1, 1 ) return CycleIndex_ ), "Category", TableB[Category], "SpaceNumber", TableB[SpaceNumber], "CycleIndex", [Value] )Execute this code in DAX Studio... By the way, your result table from above has mistakes in it. Mine seems to work correctly.
Anonymous
5 years agoNot applicable
define table
TableB =
DATATABLE(
"Category", STRING,
"SpaceNumber", INTEGER,
"Cycle", INTEGER,
{
{"A", 1, 5},
{"B", 2, 4},
{"C", 3, 4},
{"D", 1, 4},
{"E", 2, 3},
{"F", 3, 4},
{"G", 1, 4},
{"H", 2, 5},
{"I", 3, 3}
}
)
EVALUATE
SELECTCOLUMNS(
GENERATE(
TableB,
var Cycle_ = TableB[Cycle]
var SpaceNumber_ = TableB[SpaceNumber]
var Category_ = TableB[Category]
var CycleIndexStart =
1 + SUMX(
filter(
TableB,
TableB[SpaceNumber] = SpaceNumber_
&&
TableB[Category] < Category_
),
TableB[Cycle]
)
var CycleIndex_ =
GENERATESERIES(
CycleIndexStart,
CycleIndexStart + Cycle_ - 1, 1
)
return
CycleIndex_
),
"Category", TableB[Category],
"SpaceNumber", TableB[SpaceNumber],
"CycleIndex", [Value]
)Execute this code in DAX Studio... By the way, your result table from above has mistakes in it. Mine seems to work correctly.