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.
I want to get the previous value partitioned by country and order by year like the screenshot below highlighted in red.
I tried the following and the result is not as expected
Solved! Go to Solution.
Hi @sekela
This calculate column code should work
PreviousValue =
VAR CurrentCountry = Sheet1[Country]
VAR CurrentYear = Sheet1[Year]
VAR FilteredTable =
FILTER (
Sheet1,
Sheet1[Country] = CurrentCountry
&& Sheet1[Year] = CurrentYear - 1
)
VAR Result =
SUMX ( FilteredTable, Sheet1[Total Sales] )
RETURN
Result
Hi @sekela
This calculate column code should work
PreviousValue =
VAR CurrentCountry = Sheet1[Country]
VAR CurrentYear = Sheet1[Year]
VAR FilteredTable =
FILTER (
Sheet1,
Sheet1[Country] = CurrentCountry
&& Sheet1[Year] = CurrentYear - 1
)
VAR Result =
SUMX ( FilteredTable, Sheet1[Total Sales] )
RETURN
Result
Hi,
Could you add sample data in a table format and a snippet about the "not expected values"? For now, I recommend trying to reverse < directions here:
Proud to be a Super User!
Year | Country | Quantity | Unit price | Total Sales | RowNumber |
2017 | USA | 5 | 10 | 50 | 1 |
2018 | USA | 21 | 5 | 105 | 2 |
2019 | USA | 4 | 11 | 44 | 3 |
2020 | USA | 8 | 3 | 24 | 4 |
2021 | USA | 12 | 7 | 84 | 5 |
2017 | Japan | 2 | 4 | 8 | 1 |
2018 | Japan | 6 | 11 | 66 | 2 |
2019 | Japan | 8 | 2 | 16 | 3 |
2020 | Japan | 9 | 13 | 117 | 4 |
2021 | Japan | 3 | 21 | 63 | 5 |
2017 | China | 7 | 3 | 21 | 1 |
2018 | China | 8 | 1 | 8 | 2 |
2019 | China | 21 | 35 | 735 | 3 |
2020 | China | 1 | 20 | 20 | 4 |
2021 | China | 6 | 15 | 90 | 5 |
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 |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |