0

Problem to add sign + and -

let mySelect := (select Expenses where Year = 2025 and month('Expenses Date') = month(today()));
let mySelect2 := (select Expenses where Year = 2025 and month('Expenses Date') = month(today()) - 1);

let prep := sum(mySelect.'Expenses Cost');
let comparison := sum(mySelect2.'Expenses Cost');

let diffValue := number(prep) - number(comparison);
let sign := if diffValue > 0 then "+" else if diffValue < 0 then "-" else "";
let myDiff := sign + format(diffValue, "#,##0.00 €");

let desc := " Expense variation from last month ";

let content := "
<aside class='grid-container'>
    <aside>
        <i class='fas fa-chart-line' style='color:dimgray; margin-left:5px;'></i>
        <span class='short-underline'> Monthly Expenses </span>
        <br>
        <span style='color:black; font-size:16px; font-weight:bold;'> " +
    prep +
    " </span>
        <br>
        <span style='color:grey; font-size:11px; font-weight:normal;'> " +
    myDiff +
    " " +
    desc +
    " </span>
        <br>
    </aside>
    <aside class='img-container'>
        <img src='/storage/emulated/0/Download/Xpenses.jpg' height='50'>
    </aside>
";

content

 

 

I have problem with the variable sing in line 9

Need to add the sign + o - in myDiff.ñ

let diffValue := number(prep) - number(comparison);
let sign := if diffValue > 0 then "+" else if diffValue < 0 then "-" else "";
let myDiff := "" + sign + format(diffValue, "#,##0.00 €");

This doesn't work either

2 replies

null
    • Fred
    • 3 days ago
    • Reported - view

    you don't need to repeat the if:

    let diffValue := number(prep) - number(comparison);
    let sign := if diffValue > 0 then "+" else "-" end;
    let myDiff := "" + sign + format(diffValue, "#,##0.00 €");
    
      • Rafael Sanchis
      • Rafael_Sanchis
      • 3 days ago
      • Reported - view

       Thanks Fred.