Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Add a measure as a column into a matrix

My table where I have the data is like this:

Product IDCategoryAisle movementsFlag
1CarrotBefore movements1
1CarrotTo left1
1CarrotRemoved0
1CarrotFrom left-1
2ChilliBefore movements1
2ChilliRemoved-1

 

I simply would like to make a matrix that would take Product Category as rows, Aisle movement as columns and sum of flag as matrix. Then I would like to calculate (sum of flags that are < 0) / (sum of before movements) to see how much % of the products have moved away from their previous position. I would want this as 1 single column added at the end of the matrix:

Product CategoryBefore movementsTo leftFrom leftRemovedTotalMoved %
Carrot11-101=-1/1 = -100%
Chilli100-10= -1/ 1 = -100%

 

I have written a measure for this:

Moved % = calculate(sum(tbl[Flag]), tbl[Flag] < 0) / CALCULATE(SUM(tbl[Flag]), tbl[Aisle movements] = "Before movements")
But when I added this to the matrix, it also shows as other columns instead of one single column at the end. How do I switch those columns off?
 
Thank you

 

2 Replies