Unit Test Writer | DAX

Unit Test Cases for SUMX Function in DAX

These test cases evaluate the SUMX function in DAX by checking basic functionality, multiplication scenarios, negative values, zero Quantity, multiple products, and null values to ensure accurate calculations and handling of different


Empty image or helper icon

Prompt

SUMX (
    Sales,
    Sales[Quantity] * RELATED ( Products[UnitPrice] )
)

Answer

Unit Test Cases for SUMX Function in DAX

Test 1: Verify basic functionality

  • Input: Empty Sales table
  • Expected Output: 0
EVALUATE
{
    "Test 1", SUMX(Sales, Sales[Quantity] * RELATED(Products[UnitPrice]))
}

Test 2: Validate multiplication with positive values

  • Input: Sales table with Quantity = 5, UnitPrice = 10
  • Expected Output: 50
EVALUATE
{
    "Test 2", SUMX(VALUES(Sales), Sales[Quantity] * RELATED(Products[UnitPrice]))
}

Test 3: Evaluate when Quantity is negative

  • Input: Sales table with Quantity = -3, UnitPrice = 15
  • Expected Output: -45
EVALUATE
{
    "Test 3", SUMX(VALUES(Sales), Sales[Quantity] * RELATED(Products[UnitPrice]))
}

Test 4: Check behavior with zero Quantity

  • Input: Sales table with Quantity = 0, UnitPrice = 20
  • Expected Output: 0
EVALUATE
{
    "Test 4", SUMX(VALUES(Sales), Sales[Quantity] * RELATED(Products[UnitPrice]))
}

Test 5: Ensure correct calculation with multiple products

  • Input: Sales table with multiple products and quantities
  • Expected Output: Sum of (Quantity * UnitPrice) for all products
EVALUATE
{
    "Test 5", SUMX(VALUES(Sales), Sales[Quantity] * RELATED(Products[UnitPrice]))
}

Test 6: Validate behavior with null values

  • Input: Sales table with Null values
  • Expected Output: Null
EVALUATE
{
    "Test 6", SUMX(Sales, Sales[Quantity] * RELATED(Products[UnitPrice]))
}

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

These test cases evaluate the SUMX function in DAX by checking basic functionality, multiplication scenarios, negative values, zero Quantity, multiple products, and null values to ensure accurate calculations and handling of different input scenarios.