Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Test row-on-row percent change #281

Open
dtger opened this issue Sep 5, 2023 · 0 comments · May be fixed by #282
Open

[Feature Request] Test row-on-row percent change #281

dtger opened this issue Sep 5, 2023 · 0 comments · May be fixed by #282

Comments

@dtger
Copy link

dtger commented Sep 5, 2023

Is your feature request related to a problem? Please describe.
There exist tests to compare values within the column, and test if they are increasing or decreasing. However there is no solution to define acceptable rate of change.

Describe the solution you'd like
I would like to have an ability to compare relative differences between ordered values within a column.

For example:

  • order column could be date, and
  • values could be sales volume (£)

Ability to define acceptable percentage change in value from one row to the next is what I'm after. In the example above, we define threshold run test to compare whether than threshold has been met, ie:

select *
from table_name
where not(abs(test_column / nullif(previous_test_column_value, 0) - 1 < change_threshold))

where

  • test_column is the column we're testing for changes in
  • previous_test_column_value = lag(test_column)
  • change_threshold is ratio of change we find acceptable, expressed as fractional percent (10% = 0.1)

Describe alternatives you've considered
There are no alternatives I have found that solved this specific case

Additional context
PR incoming, as I have the test running in my current project

@dtger dtger changed the title [Feature Request] [Feature Request] Test row-on-row percent change Sep 5, 2023
@dtger dtger linked a pull request Sep 5, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant