Forum Discussion
Daily Position
- Anonymous8 years ago
Hi LuisBassetti,
Please check below sample if it suitable for your requirement.
1. Create a table with begin/end type of each records.
Analysis = CROSSJOIN ( DISTINCT ( SELECTCOLUMNS ( Sheet1, "Code", [Code], "Date", [Date], "Item", [Item], "Local", [Local], "Month", [Month] ) ), UNION ( ROW ( "Type", "a_Begin" ), ROW ( "Type", "z_End" ) ) )2. Add QTY column to calculate the amount.
QTY = var temp= LOOKUPVALUE (Sheet2[Qty],Sheet2[Code], [Code], Sheet2[Date], DATE([Date].[Year],[Date].[MonthNo],1) ) RETURN SWITCH ( [Type], "a_Begin",temp + SUMX ( FILTER ( ALL(Sheet1), Sheet1[Code] = EARLIER ( [Code] ) && Sheet1[Date] < EARLIER ( [Date] ) ), [QTY] ), "z_End", temp + SUMX ( FILTER ( ALL(Sheet1), Sheet1[Code] = EARLIER ( [Code] ) && Sheet1[Date] <= EARLIER ( [Date] ) ), [QTY] ), 0 )3. Format analysis table and union original table.
Merged = UNION(Sheet1,SELECTCOLUMNS(Analysis,"Code",[Code],"Item",[Item],"Type",[Type],"I/O","","QTY",[Qty],"Local",[Local],"Date",[Date],"Month",[Month]))
4. Use above table to create matrix visual.
Notice: I have shared the sample file as the attachment.
Regards,
Xiaoxin Sheng
Hi LuisBassetti,
Please check below sample if it suitable for your requirement.
1. Create a table with begin/end type of each records.
Analysis =
CROSSJOIN (
DISTINCT (
SELECTCOLUMNS (
Sheet1,
"Code", [Code],
"Date", [Date],
"Item", [Item],
"Local", [Local],
"Month", [Month]
)
),
UNION ( ROW ( "Type", "a_Begin" ), ROW ( "Type", "z_End" ) )
)
2. Add QTY column to calculate the amount.
QTY =
var temp= LOOKUPVALUE (Sheet2[Qty],Sheet2[Code], [Code], Sheet2[Date], DATE([Date].[Year],[Date].[MonthNo],1) )
RETURN
SWITCH (
[Type],
"a_Begin",temp
+ SUMX (
FILTER (
ALL(Sheet1),
Sheet1[Code] = EARLIER ( [Code] )
&& Sheet1[Date] < EARLIER ( [Date] )
),
[QTY]
),
"z_End", temp
+ SUMX (
FILTER (
ALL(Sheet1),
Sheet1[Code] = EARLIER ( [Code] )
&& Sheet1[Date] <= EARLIER ( [Date] )
),
[QTY]
),
0
)
3. Format analysis table and union original table.
Merged = UNION(Sheet1,SELECTCOLUMNS(Analysis,"Code",[Code],"Item",[Item],"Type",[Type],"I/O","","QTY",[Qty],"Local",[Local],"Date",[Date],"Month",[Month]))
4. Use above table to create matrix visual.
Notice: I have shared the sample file as the attachment.
Regards,
Xiaoxin Sheng
That's exactly what I need! Thank you so much!!