PRODUCTX DAX Function (Aggregation)

Returns the product of an expression values in a table.

Syntax

PRODUCTX ( <Table>, <Expression> )
Parameter Attributes Description
Table
Iterator

Table over which the Expression will be evaluated.

Expression
Row Context

Expression to evaluate for each row of the table.

Return values

Scalar A single decimal value.

The product of the Expression evaluated for each row in the Table.

Remarks

PRODUCTX ignores blank expressions, the multiplication operator does not.

By using ^ -1 skipping the first row, you can use PRODUCTX to obtain the result of a DIVIDEX function (which is not available in DAX).

-- Apply PRODUCTX to Table[Column]
PRODUCTX ( Table, Table[Column] )

-- Apply an hypothetical DIVIDEX function to Table[Column] by using PRODUCTX
PRODUCTX ( 
    Table, 
    -- Avoid the IF in the iterator for performance reasons
    Table[Column] ^ (1 - 2 * ( Table[RowNumber] > 1 ) ) 
)
» 2 related articles
» 1 related function

Examples

 
-- PRODUCT is the short version of PRODUCTX
-- PRODUCTX multiplies values in the rows it scans
--
-- The report shows the actualized sales in 2009 by applying 
-- the inflation rate in sales made in previous years
DEFINE
    MEASURE Rates[Compound Inflation Rate] =
        PRODUCTX ( Rates, 1 + Rates[InflationRate] )
    MEASURE Sales[Sales Amount] =
        SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
    MEASURE Sales[Actualized Sales 2009] =
        SUMX (
            VALUES ( 'Date'[Calendar Year Number] ),
            VAR ReferenceYear = 2009
            VAR BaseYear = 'Date'[Calendar Year Number]
            VAR CompoundRate =
                CALCULATE (
                    COALESCE ( [Compound Inflation Rate], 1 ),
                    Rates[Year] >= BaseYear && Rates[Year] < ReferenceYear
                )
            RETURN [Sales Amount] * CompoundRate
        )
    MEASURE Sales[Adjustment %] =
        VAR ReferenceYear = 2009
        VAR BaseYear = SELECTEDVALUE ( 'Date'[Calendar Year Number] )
        VAR CompoundRate =
            CALCULATE (
                COALESCE ( [Compound Inflation Rate], 1 ),
                Rates[Year] >= BaseYear && Rates[Year] < ReferenceYear
            )
        RETURN IF ( 
            NOT ISBLANK ( BaseYear ) && NOT ISBLANK ( [Sales Amount] ), 
            CompoundRate 
        )
        
EVALUATE Rates 

EVALUATE
SUMMARIZECOLUMNS (
    ROLLUPADDISSUBTOTAL ( 'Date'[Calendar Year], "IsTotal" ),
    "Sales Amount", [Sales Amount],
    "Adjustment %", [Adjustment %],
    "Actualized Sales 2009", [Actualized Sales 2009]
)
ORDER BY [IsTotal], [Calendar Year]
Year InflationRate
2,005 0.03
2,006 0.03
2,007 0.03
2,008 0.04
2,009 0.00
2,010 0.02
Calendar Year IsTotal Sales Amount Adjustment % Actualized Sales 2009
2007-01-01 false 11,309,946.12 106.80% 12,078,959.12
2008-01-01 false 9,927,582.99 103.84% 10,308,802.18
2009-01-01 false 9,353,814.87 100.00% 9,353,814.87
(Blank) true 30,591,343.98 (Blank) 31,741,576.16

Related articles

Learn more about PRODUCTX in the following articles:

Related functions

Other related functions are:

Last update: Nov 19, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Ashley Garoutte, Steve Yamashiro, Kenneth Barber

Microsoft documentation: https://docs.microsoft.com/en-us/dax/productx-function-dax

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of PRODUCTX? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.