Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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?
Solved! Go to Solution.
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
)
@Anonymous ,
Which value are you expecting in place of x,y,z? Please provide any logic or formula.
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.
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
)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 44 | |
| 40 | |
| 18 | |
| 18 |
| User | Count |
|---|---|
| 69 | |
| 69 | |
| 32 | |
| 32 | |
| 32 |