Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
which syntax would be correct for selected year sales, i am getting same output.
Sum({<Year= {$(=(year))}>}Sales)
or
Sum({<Year= {$(=only(year))}>}Sales)
Need more info on how your visualization looks to help properly
let me give a shot and hope i dont confuse the hell out of you 🙂
scenario 1 - Supposing you want to show selected year vs previous year
current year expression - Sum({<Year= {$(=only(year))}>}Sales)
previous year expression - Sum({<Year= {$(=only(year)-1)}>}Sales)
but using only() when more than 1 possible value exists (i.e. in this case no selection is made on year filter) will return null i.e. your expression returns null or 0
scenario 2 - same as above but if nothing is selected you want to current (max) year vs previous year
current year expression - Sum({<Year= {$(=max(year))}>}Sales)
previous year expression - Sum({<Year= {$(=max(year)-1)}>}Sales)
i.e. if you have data from 2012-2019 by default you show 2019 vs 2018. if user selects year 2017. you show 2017 vs 2016
hope its clear
Rule of thumb:
Typing a field name, MyField, in an expression is equivalent to Only(MyField).
Sum({<Year= {$(=(year))}>}Sales) is the same as Sum({<Year= {$(=only(year))}>}Sales)
Sum(Sales) + ExchangeRate is the same as Sum(Sales) + only(ExchangeRate)
Need more info on how your visualization looks to help properly
let me give a shot and hope i dont confuse the hell out of you 🙂
scenario 1 - Supposing you want to show selected year vs previous year
current year expression - Sum({<Year= {$(=only(year))}>}Sales)
previous year expression - Sum({<Year= {$(=only(year)-1)}>}Sales)
but using only() when more than 1 possible value exists (i.e. in this case no selection is made on year filter) will return null i.e. your expression returns null or 0
scenario 2 - same as above but if nothing is selected you want to current (max) year vs previous year
current year expression - Sum({<Year= {$(=max(year))}>}Sales)
previous year expression - Sum({<Year= {$(=max(year)-1)}>}Sales)
i.e. if you have data from 2012-2019 by default you show 2019 vs 2018. if user selects year 2017. you show 2017 vs 2016
hope its clear