Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys, i get 55 for firm A using
FirstSortedValue(measure, key_date)
while i select January 2024 and Firm A in my app.
I also want to get the 2023 value as comparison using
FirstSortedValue(measure, AddYears(key_date, -1)
. This however didn't work. Then i tried set analysis to preselect the data to analyse like
FirstSortedValue({<key_date= {">=$(=Date(AddYears(Min(key_date), -1))) <=$(=Date(AddYears(Max(key_date), -1)))"} measure, key_date)
that didn't work as well.
Following an simplified example of the data. Can someone help?
| key_date | firm | measure |
| 01.01.2023 | A | 100 |
| 01.01.2023 | B | 5 |
| 01.01.2023 | C | 200 |
| 02.01.2023 | A | 10 |
| 02.01.2023 | B | 20 |
| 02.01.2023 | C | 3 |
| … | ||
| 31.01.2023 | A | 33 |
| … | ||
| 01.01.2024 | A | 55 |
| 01.01.2024 | B | 2 |
| 01.01.2024 | C | 43 |
| 02.01.2024 | A | 67 |
| 02.01.2024 | B | 3 |
| 02.01.2024 | C | 1 |
| … | ||
| 31.01.2024 | A | 5 |
I finally get it to work with this
{<[key_date.autoCalendar.Year]={"$(=Min(Year(key_date)) - 1)"}>} firstsortedvalue(measure, key_date)
, but i don't really understand why ...
@Yi_DE what is expected output?
Hi @Kushal_Chawda , the expected output is 100, the top line in the table.
@Yi_DE I don't think you need firstsorted value. You can use below set
=sum({<key_date={"$(=date(addyears(min(key_date),-1)))"}>} measure)
@Kushal_Chawda This approach returns 0 as result, even though the key_date has the correct value of 01.01.2023
I finally get it to work with this
{<[key_date.autoCalendar.Year]={"$(=Min(Year(key_date)) - 1)"}>} firstsortedvalue(measure, key_date)
, but i don't really understand why ...