Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Difference between columns coming from same row in matrix

I have a sample data:

Week numberCategorySales
1MessT1234
2WerkZ2345

 

From this I created a matrix table which calculates a sum of sales in a given week. it looks like in a screenshot.

I read docs about how to create a measure with differences between these categories and a % diff, but I am getting blanks. Why is that? 

 

From two tutorials I am trying two columns:

 

the diff2 column is 

 

Diff2 = CALCULATE(
    SUM([items.netRevenue]),FILTER(invoices_granular, invoices_granular[WeekNum]=MAX(invoices_granular[WeekNum]) 
    - CALCULATE(
    SUM(invoices_granular[items.netRevenue]),FILTER(invoices_granular,invoices_granular[WeekNum]=MIN(invoices_granular[WeekNum]) 
))
))

 


and Difference between Cat is:

 

Difference btw Cat = 
    IF (
        HASONEVALUE(invoices_granular[WeekNum]),
        BLANK(),
        CALCULATE( 
            SUM(invoices_granular[items.netRevenue]),
            FILTER(invoices_granular, invoices_granular[WeekNum] = MAX(invoices_granular[WeekNum]))
        )
        - CALCULATE(
            SUM(invoices_granular[items.netRevenue]),
            FILTER(invoices_granular,invoices_granular[WeekNum] = MIN(invoices_granular[WeekNum]))
        )
    )

 

2 Replies