Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi everyone,
I'm working on a table which contains informations about some orders and I want to display in a visual the sum of the current year sales and the sum of the previous year sales. Classic problem I guess, so I looked on internet and found a lot of topics for this but all were working with dates. However, In my tables the year is stored as an integer (ex: 2023, 2022...). So I built my own measure which works pretty well, I can obtain the annual sales for the year before the one selected in my slicer:
previous =
VAR PY =
SELECTEDVALUE(Clients[InvoiceYear]) - 1
RETURN
CALCULATE (
[Sum of sales],
FILTER (
ALL ( Orders ),
Orders[InvoiceYear] = PY
)
)
(I want to filter my data on the invoice year of the table Clients.)
But now I'm facing another problem : this measure can't be filtered. When I want to display it in a table with clients codes (stored in Clients table) for example, the value of the total year sales is displayed in each row and I'm not able to have the year sales by client and I really don't understand why.
Did someone can help me please ?
Best regards,
Clément
Solved! Go to Solution.
previous =
VAR PY =
MAX(Clients[InvoiceYear]) - 1
RETURN
CALCULATE (
[Sum of sales],
REMOVEFILTERS([column with slicer]),
Orders[InvoiceYear] = PY
)
@clementalba Maybe:
previous =
VAR PY =
SELECTEDVALUE(Clients[InvoiceYear]) - 1
VAR ClientCode = MAX('Clients'[Code])
RETURN
CALCULATE (
[Sum of sales],
FILTER (
ALL ( Orders ),
Orders[Client Code] = ClientCode,
Orders[InvoiceYear] = PY
)
)
previous =
VAR PY =
MAX(Clients[InvoiceYear]) - 1
RETURN
CALCULATE (
[Sum of sales],
REMOVEFILTERS([column with slicer]),
Orders[InvoiceYear] = PY
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
10 | |
10 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |