Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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 |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
19 |