evidence-dev / evidence

Business intelligence as code: build fast, interactive data visualizations in pure SQL and markdown
https://evidence.dev
MIT License
3.44k stars 167 forks source link

BigValue downIsGood not working properly #1973

Closed adgramigna closed 1 week ago

adgramigna commented 1 week ago

Steps To Reproduce

Code snippet with needful things data. I'm aware logically this would be an example for downIsGood should be the default value of false, but for illustrative purposes, let's pretend we want less purchases on "Sinister Toys" and therefore downIsGood should be set to true.

View issue as raw text as markdown formatting is hiding some of the needed code for Evidence. I've attached a screenshot of the code just in case

Screenshot 2024-05-05 at 3 45 23 PM
  select 
      date_trunc('month', order_datetime) as month,
      sum(sales) as sales_usd,
      category
  from needful_things.orders
  where category = 'Sinister Toys'
  and (date_trunc('month', order_datetime) >= '2021-11-01')
  group by all
  order by 1 desc
with create_monthly_change as (
    select 
    category,
    lag(sales_usd) over() - sales_usd as monthly_change,
    case when month = '2021-11-01' then sales_usd end as nov_sales,
    case when month = '2021-12-01' then sales_usd end as dec_sales,
from ${orders_by_category}
)

select
    category,
    max(monthly_change) as monthly_change,
    max(nov_sales) as nov_sales,
    max(dec_sales) as dec_sales,
from create_monthly_change
group by 1

<BigValue data={error_data} value=dec_sales title="Poor Moves Severe Pressure" fmt=#,##0.00$ comparison=monthly_change downIsGood=true comparisonTitle="from prior month" comparisonFmt=#,##0.00$ />

Environment

Expected Behavior

the downIsGood parameter is supposed to flip the colors for Red and Green in the comparison

Actual Behaviour

Parameter does not work. downIsGood=true has the same effect as downIsGood=false, positive numbers are green and negative numbers are red

Workarounds

None that I know of