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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Need help - Column difference in a matrix

Good afternoon all!

 

I'm in dire need of some help.

 

I have the following matrix making use of 3 fields:

 

  • Description
  • Period
  • Cost

Help please.png

My issue is the following, i want to add a column next to the 2 dates which does a value of 202002 - value of 202001 

 

i want it to only to the difference based on the 2 periods i selected in the filter visual.

 

Any help would be appreciated or guidance on how to do it better.

 

Regards 

 

 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create measures

Measure 2 =
VAR m1 =
    MINX (
        ALLSELECTED ( 'Table 2' ),
        [period]
    )
VAR m2 =
    MAXX (
        ALLSELECTED ( 'Table 2' ),
        [period]
    )
RETURN
    CALCULATE (
        SUM ( 'Table 2'[cost] ),
        FILTER (
            'Table 2',
            'Table 2'[period] = m2
        )
    )
        - CALCULATE (
            SUM ( 'Table 2'[cost] ),
            FILTER (
                'Table 2',
                'Table 2'[period] = m1
            )
        )


Measure = IF(ISINSCOPE('Table 2'[period]),SUM('Table 2'[cost]),[Measure 2])

Capture4.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
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

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create measures

Measure 2 =
VAR m1 =
    MINX (
        ALLSELECTED ( 'Table 2' ),
        [period]
    )
VAR m2 =
    MAXX (
        ALLSELECTED ( 'Table 2' ),
        [period]
    )
RETURN
    CALCULATE (
        SUM ( 'Table 2'[cost] ),
        FILTER (
            'Table 2',
            'Table 2'[period] = m2
        )
    )
        - CALCULATE (
            SUM ( 'Table 2'[cost] ),
            FILTER (
                'Table 2',
                'Table 2'[period] = m1
            )
        )


Measure = IF(ISINSCOPE('Table 2'[period]),SUM('Table 2'[cost]),[Measure 2])

Capture4.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

thank you very much! Works like a charm!

 

thanks to everyone else who also gave inputs and solutions.

 

appreciate it!

 

Nishantjain
Continued Contributor
Continued Contributor

@Anonymous 

 

Below is a suggestion

 

Create 3 measures

 

Measure 1

Previous Period = 
VAR mindate = min(period)
return
Calculate(Sum(Data[values]), Period[period] = mindate)

 

 

Measure 2: 

Latest period= 
VAR maxdate = max(period)
return
Calculate(Sum(Data[values]), Period[period] = maxdate)

 

Measure 3: 

Variance = [Measure 1] - [Measure 2]

 

Drop each of these measures in your matrix and remove the period field from the matrix

 

Few things to note:

 

1. If you select more than 3 period, it will automatically default to 2 period selecting the minimum and maximum date

2. The column headers will not show the period name, but would show the name of the measure

 

amitchandak
Super User
Super User

Make sure period are in a separate table for better working

Measure =
var _min = minx(Period,Period[Name])
var _max = maxx(Period,Period[Name])
return
calculate(sum(table[cost]),filter(all(Period),Period[Name]=_min)) -calculate(sum(table[cost]),filter(all(Period),Period[Name]=_max))

 

if you need more help make me @

Appreciate your Kudos.

 

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

thanks @amitchandak , i tried this and didnt give any errors, but it doesnt want to do the calculation. It just returns a 0.

 

Help please2.png

 

Can you share sample data and sample output.

 

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors