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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Variance Column

I have a matrix that looks like this

 

company             2022               2023            2024

orders                   2342              1234            5678

sales                       2342              1234            5678

income                   2342              1234            5678

 

I want to add a column that is year by year variance, so it should look like this

 

 

company             2022               2023            2024             Variance

orders                   2342              1234            5678                    x

sales                       2342              1234            5678                  y

income                   2342              1234            5678               z

 

I want the variance column to be filled in with the orders vs last year, sales vs last year, and income vs last year. How would I be able to do this?

 

1 ACCEPTED SOLUTION
aduguid
Memorable Member
Memorable Member

Give this measure a try 

Yearly Variance = 
VAR CurrentYear = SELECTEDVALUE('Date'[Year])
VAR PreviousYear = CurrentYear - 1
VAR Metric = SELECTEDVALUE('Metrics'[Metric])

RETURN
SWITCH(
    TRUE(),
    Metric = "Orders", [Orders],
    Metric = "Sales", [Sales],
    Metric = "Income", [Income]
) - 
CALCULATE(
    SWITCH(
        TRUE(),
        Metric = "Orders", [Orders],
        Metric = "Sales", [Sales],
        Metric = "Income", [Income]
    ),
    'Date'[Year] = PreviousYear
)

View solution in original post

4 REPLIES 4
Arul
Super User
Super User

@Anonymous ,

Which value are you expecting in place of x,y,z? Please provide any logic or formula.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Anonymous
Not applicable

variance of orders from 2023 to 2024 in x, variance of sales from 2023 to 2024 in y, variance of income from 2023 to 2024 in z

@Anonymous ,

Correct if me if I'm wrong,

2024[orders]-2023[orders] likewise for others.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


aduguid
Memorable Member
Memorable Member

Give this measure a try 

Yearly Variance = 
VAR CurrentYear = SELECTEDVALUE('Date'[Year])
VAR PreviousYear = CurrentYear - 1
VAR Metric = SELECTEDVALUE('Metrics'[Metric])

RETURN
SWITCH(
    TRUE(),
    Metric = "Orders", [Orders],
    Metric = "Sales", [Sales],
    Metric = "Income", [Income]
) - 
CALCULATE(
    SWITCH(
        TRUE(),
        Metric = "Orders", [Orders],
        Metric = "Sales", [Sales],
        Metric = "Income", [Income]
    ),
    'Date'[Year] = PreviousYear
)

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors