Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everybody,
I need to create an expression in a chart and filter the values by using a set analysis. Here is the idea:
KPI = Sum({<(Field 1 - Field 2)-={0}>} Amount)
(exclude the values where the result of the formula is =0)
I am not sure if this is possible and what would be the syntax.
Thanks for your help in advance.
Try like this
Sum({<[Voucher Code] = {"=Sum({<[Date] = {[>=$(v_DateIssue_1)<=$(v_DateIssue_2)]}>} [Voucher Issue Amount]) - Sum({"=Sum({<[Date] = {[>=$(v_DateIssue_1)<=$(v_DateIssue_2)]} [Voucher Used Amount]) <> 0"}, [Date] = {">=$(v_DateIssue_1)<=$(v_DateIssue_2)"}>} [Voucher Issue Amount])
Basically use [] instead of double quotes around the inner set analysis... you can also use escape sequence by using 2 double quotes within the inner set analysis
Sum({<[Voucher Code] = {"=Sum({<[Date] = {"">=$(v_DateIssue_1)<=$(v_DateIssue_2)""}>} [Voucher Issue Amount]) - Sum({"=Sum({<[Date] = {"">=$(v_DateIssue_1)<=$(v_DateIssue_2)""} [Voucher Used Amount]) <> 0"}, [Date] = {">=$(v_DateIssue_1)<=$(v_DateIssue_2)"}>} [Voucher Issue Amount])
Against which dimension are you checking Field1 - Field is not equal to 0? Lets Call it DimX... try this
Sum({<DimX = {"=(Field1 - Field2) <> 0"}>} Amount)
Hi,
Maybe not the best approach but,
IF( SUM(Field1 - Field2) = 0, SUM(Amount))
should do the trick.
Mark
Actually, it's not a dimension that I'm checking but the result of two facts.
In the data model we have:
Dimension: Voucher
Fact 1: Voucher Amount (issue value)
Fact 2 (several possible): Voucher Amount Used (a voucher car be used partially, so many usages)
The chart should not include vouchers without remaining value (=0). So that's why i try to filter the liste through set analysis:
Here is an example with data: the last line should not appear in the chart.
Does a Voucher code can only have one and only one voucher date issue? If it does, then you can try this
Sum({<[Voucher Code] = {"=Sum([Voucher Issue Amount]) - Sum([Voucher Used Amount]) <> 0"}>} [Voucher Issue Amount]) Sum({<[Voucher Code] = {"=Sum([Voucher Issue Amount]) - Sum([Voucher Used Amount]) <> 0"}>} [Voucher Used Amount])
Yes, there is only one date issue.
I tried your suggestion but I have some syntaxe issue because I have also set analysis in the Sum (Voucher Amount)
Sum({<[Date]={">=$(v_DateIssue_1) <=$(v_DateIssue_2)"}>}[Voucher Issue Amount])
Here is the complete KPI in this case:
Sum({<[Voucher Code] = {"=Sum({set analysis as above}[Voucher Issue Amount]) - Sum({set analysis as above}[Voucher Used Amount]) <> 0"}, set analysis as above >} [Voucher Issue Amount])
But there is a syntax issue because of the quotes in the second set analysis.
This would not work in load script because the chart is based on date selection. And at a given time a voucher can have a remaining value.
Try like this
Sum({<[Voucher Code] = {"=Sum({<[Date] = {[>=$(v_DateIssue_1)<=$(v_DateIssue_2)]}>} [Voucher Issue Amount]) - Sum({"=Sum({<[Date] = {[>=$(v_DateIssue_1)<=$(v_DateIssue_2)]} [Voucher Used Amount]) <> 0"}, [Date] = {">=$(v_DateIssue_1)<=$(v_DateIssue_2)"}>} [Voucher Issue Amount])
Basically use [] instead of double quotes around the inner set analysis... you can also use escape sequence by using 2 double quotes within the inner set analysis
Sum({<[Voucher Code] = {"=Sum({<[Date] = {"">=$(v_DateIssue_1)<=$(v_DateIssue_2)""}>} [Voucher Issue Amount]) - Sum({"=Sum({<[Date] = {"">=$(v_DateIssue_1)<=$(v_DateIssue_2)""} [Voucher Used Amount]) <> 0"}, [Date] = {">=$(v_DateIssue_1)<=$(v_DateIssue_2)"}>} [Voucher Issue Amount])