Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

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]))
        )
    )

 

Screenshot 2023-10-05 at 14.23.09.png

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Make sure you have separate week or date table and then try approch like

 

Have these new columns in Date Table, Week Rank is Important in Date/Week Table

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format


These measures can help
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak This is not exactly what I need I think.

I made a separate date table, and changed the formula and still I get blank values. 

I want to calculate a difference  for categories 0 as in screenshot, sales on 7/7/23 for category Messtechnik are 11k, and for category Werkzeuge are 4,9k. I want the difference to populate and show 6k. Instead I am getting blanks.

I followed tutorials and not sure what I missed

 

Screenshot 2023-10-06 at 11.08.08.png

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.