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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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.

 

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.

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.