Forum Discussion

Excellove15's avatar
Excellove15
Iron Contributor
Sep 27, 2024

Combining Two dax measures to avoid dax reference

Hi Team,

 

I have created two dax codes as below:

 

Related_(Target cost)_1 =
VAR TargetValue =
    CALCULATE (
        SUM ( Target[Value] ),
        'Target'[DBName-Point_id] = MAX ( 'Accruals'[DBName-Point_Id] )
            && 'Target'[TargetType] = 1
            && 'Target'[month] = FORMAT ( MAX ( 'Accruals'[Date] ), "mmmm" )
    )
VAR days =
    SUMX ( 'Accruals', TargetValue )
RETURN
    --days/[no of days]
    COALESCE ( days / [no of days], 0 )
Target cost_1 =
SUMX ( 'Accruals', COALESCE ( [Related_(Target cost)_1], 0 ) )

 

 

Their results individually as shown below

 

 

Is it possible to merge these dax measures into a single dax ? Also, final values at the total & column will be same as below ?

 

I am doing this in order to avoid the reference of measures within another dax.

Please help me.

 

Thanks in advance!

SergeiBaklan 

2 Replies

  • LiamStorm's avatar
    LiamStorm
    Iron Contributor

    Sometimes, you may want to avoid a circular reference without creating separate measures. You can use variables within your DAX measure to store intermediate calculations.

  • VaughnPierce's avatar
    VaughnPierce
    Iron Contributor

    It seems you want to combine two DAX measures into a single measure in order to avoid DAX reference issues.

Resources