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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Mr_Stern
Frequent Visitor

calculating diferences between columns in matrix

Hi,

Still a beginer at BI, so having issues with this one, any help would be appreciated.

I have a matrix that I have built.

In the columns are the past 13 weeks, rows show clients, and then hours are the value.

I need to add a column at the end that will calculate the movement between the first week in the matrix and the last week in the matrix.

*Note that this does not show all the data, data goes back further than 13 weeks, it is just filtered to show the most recent quarter.

 

E.g. (just using 5 weeks for sample)

 

ClientW1W2W3W4W5Movement(need help here)

Jane

14202832206
Joe7248121812(60)
Sam78787070780
Sue163040404024
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Mr_Stern 

 

Please try this:

Here I add your data:

vzhengdxumsft_0-1717121382489.png

Then add a measure:

MEASURE =
VAR _Vtable =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        'Table'[WeekNum],
        "WeekNo.", MID ( 'Table'[WeekNum], 2, 3 )
    )
VAR _diff =
    CALCULATE (
        SUM ( 'Table'[Hours] ),
        'Table'[WeekNum] = MAXX ( _Vtable, [WeekNum] )
    )
        - CALCULATE (
            SUM ( 'Table'[Hours] ),
            'Table'[WeekNum] = MINX ( _Vtable, [WeekNum] )
        )
RETURN
    IF (
        HASONEVALUE ( 'Table'[WeekNum] ),
        SUM ( 'Table'[Hours] ),
        IF ( _diff < 0, "(" & ABS ( _diff ) & ")", _diff )
    )

Then add a matrix:

vzhengdxumsft_1-1717121442452.png

In the format pane, change the Subtotal label in the Column subtotals:

vzhengdxumsft_2-1717121628932.png

The result is as follow:

vzhengdxumsft_3-1717121644326.png

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Mr_Stern 

 

Please try this:

Here I add your data:

vzhengdxumsft_0-1717121382489.png

Then add a measure:

MEASURE =
VAR _Vtable =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        'Table'[WeekNum],
        "WeekNo.", MID ( 'Table'[WeekNum], 2, 3 )
    )
VAR _diff =
    CALCULATE (
        SUM ( 'Table'[Hours] ),
        'Table'[WeekNum] = MAXX ( _Vtable, [WeekNum] )
    )
        - CALCULATE (
            SUM ( 'Table'[Hours] ),
            'Table'[WeekNum] = MINX ( _Vtable, [WeekNum] )
        )
RETURN
    IF (
        HASONEVALUE ( 'Table'[WeekNum] ),
        SUM ( 'Table'[Hours] ),
        IF ( _diff < 0, "(" & ABS ( _diff ) & ")", _diff )
    )

Then add a matrix:

vzhengdxumsft_1-1717121442452.png

In the format pane, change the Subtotal label in the Column subtotals:

vzhengdxumsft_2-1717121628932.png

The result is as follow:

vzhengdxumsft_3-1717121644326.png

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.