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

feat(formula): add logical functions #2644

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

Hossein-Khan
Copy link
Contributor

Summary

This PR adds implementations for the following logical functions:

  • IFNA
  • IFS
  • NOT
  • XOR
  • FALSE
  • TRUE
  • SWITCH

Changes

  • Added new classes for each logical function in the appropriate directory.
  • Ensured each function follows the existing structure and conventions.
  • Added unit tests for each new function.

Copy link

github-actions bot commented Jun 30, 2024

View Deployment

📑 Examples 📚 Storybook
🔗 Preview link 🔗 Preview link

expect(result.getValue()).toBe(ErrorType.NAME);
});

it('Value is array', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to support array formulas, like
image

import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { BaseFunction } from '../../base-function';

export class Ifs extends BaseFunction {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formulas with multiple input parameters need to consider array expansion. For expansion of ranges of different sizes, refer to the use of expandArrayValueObject method.
image

import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';

export class Not extends BaseFunction {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to support array formulas
image


override maxParams = 255;

override calculate(expression: BaseValueObject, ...casesAndResults: BaseValueObject[]): BaseValueObject {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to support array formulas, like
image

import { BaseFunction } from '../../base-function';

export class Xor extends BaseFunction {
override minParams = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=XOR(C1:C3>0,E1:G1<10,J1:J4) gets TRUE
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hossein-Khan Still need to be resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, could you please explain more about what the issue is with the XOR function?

@Dushusir
Copy link
Member

Dushusir commented Jul 1, 2024

Please pay attention to the failure CI

@Dushusir Dushusir added the qa:untested This PR is ready to be tested label Jul 6, 2024
@dream-num dream-num deleted a comment from univer-bot bot Jul 6, 2024
@dream-num dream-num deleted a comment from univer-bot bot Jul 6, 2024
@dream-num dream-num deleted a comment from univer-bot bot Jul 6, 2024
@dream-num dream-num deleted a comment from zhaolixin7 Jul 8, 2024
@dream-num dream-num deleted a comment from univer-bot bot Jul 8, 2024
@dream-num dream-num deleted a comment from zhaolixin7 Jul 10, 2024
@dream-num dream-num deleted a comment from univer-bot bot Jul 10, 2024
@dream-num dream-num deleted a comment from zhaolixin7 Jul 15, 2024
@dream-num dream-num deleted a comment from univer-bot bot Jul 15, 2024
@dream-num dream-num deleted a comment from zhaolixin7 Jul 15, 2024
@dream-num dream-num deleted a comment from univer-bot bot Jul 15, 2024
@Dushusir
Copy link
Member

@zhaolixin7 zhaolixin7 added the qa:verified This PR has already by verified by a QA and is considered good enough to be merge label Jul 16, 2024
@univer-bot univer-bot bot removed the qa:untested This PR is ready to be tested label Jul 16, 2024
@Dushusir Dushusir merged commit 3e3e572 into dream-num:dev Aug 7, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qa:verified This PR has already by verified by a QA and is considered good enough to be merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants