Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
DionTN
Helper II
Helper II

Add quick calculations as new column

DionTN_0-1661761231272.png

The upper table is the result i want. So for "lichaamssamenstelling" I want a result of 7.63 in the left column second table. My calculation works as you can see in the third column. Why is this not working in the folowing function?

 

Kolom =
IF (
    webgraph[Category] = "Lichaamssamenstelling",
    AVERAGEX (
        KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
        CALCULATE ( AVERAGE ( 'calctable'[BodyComp2] ) )
    ),
    IF (
        webgraph[Category] = "cardio",
        AVERAGEX (
            KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
            CALCULATE ( AVERAGE ( 'calctable'[cardio2] ) )
        ),
        IF (
            webgraph[Category] = "Microcirculatie",
            AVERAGEX (
                KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                CALCULATE ( AVERAGE ( 'calctable'[Micro2] ) )
            ),
            IF (
                webgraph[Category] = "stress",
                AVERAGEX (
                    KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                    CALCULATE ( AVERAGE ( 'calctable'[stress2] ) )
                ),
                IF (
                    webgraph[Category] = "Vertebraal",
                    AVERAGEX (
                        KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                        CALCULATE ( AVERAGE ( 'calctable'[Vert2] ) )
                    ),
                    0
                )
            )
        )
    )
)

In my opinion the calculation is identical to the quick calculation in the 3th column:

Gemiddelde van BodyComp2 per LastValue = 
AVERAGEX(
	KEEPFILTERS(VALUES('calctable'[LastValue])),
	CALCULATE(AVERAGE('calctable'[BodyComp2]))
)
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @DionTN 

 

Do you mean "Quick measure" by "quick calculation"? Your [Kolom] is a calculated column rather than a measure, so the measure DAX will work differently when it's applied to a calculated column. You can try below code to create a measure and add it to the table visual to check the result.

vjingzhang_1-1662023339929.png

New Measure =
IF (
    SELECTEDVALUE ( webgraph[Category] ) = "Lichaamssamenstelling",
    AVERAGEX (
        KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
        CALCULATE ( AVERAGE ( 'calctable'[BodyComp2] ) )
    ),
    IF (
        SELECTEDVALUE ( webgraph[Category] ) = "cardio",
        AVERAGEX (
            KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
            CALCULATE ( AVERAGE ( 'calctable'[cardio2] ) )
        ),
        IF (
            SELECTEDVALUE ( webgraph[Category] ) = "Microcirculatie",
            AVERAGEX (
                KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                CALCULATE ( AVERAGE ( 'calctable'[Micro2] ) )
            ),
            IF (
                SELECTEDVALUE ( webgraph[Category] ) = "stress",
                AVERAGEX (
                    KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                    CALCULATE ( AVERAGE ( 'calctable'[stress2] ) )
                ),
                IF (
                    SELECTEDVALUE ( webgraph[Category] ) = "Vertebraal",
                    AVERAGEX (
                        KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                        CALCULATE ( AVERAGE ( 'calctable'[Vert2] ) )
                    ),
                    0
                )
            )
        )
    )
)

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @DionTN 

 

Do you mean "Quick measure" by "quick calculation"? Your [Kolom] is a calculated column rather than a measure, so the measure DAX will work differently when it's applied to a calculated column. You can try below code to create a measure and add it to the table visual to check the result.

vjingzhang_1-1662023339929.png

New Measure =
IF (
    SELECTEDVALUE ( webgraph[Category] ) = "Lichaamssamenstelling",
    AVERAGEX (
        KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
        CALCULATE ( AVERAGE ( 'calctable'[BodyComp2] ) )
    ),
    IF (
        SELECTEDVALUE ( webgraph[Category] ) = "cardio",
        AVERAGEX (
            KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
            CALCULATE ( AVERAGE ( 'calctable'[cardio2] ) )
        ),
        IF (
            SELECTEDVALUE ( webgraph[Category] ) = "Microcirculatie",
            AVERAGEX (
                KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                CALCULATE ( AVERAGE ( 'calctable'[Micro2] ) )
            ),
            IF (
                SELECTEDVALUE ( webgraph[Category] ) = "stress",
                AVERAGEX (
                    KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                    CALCULATE ( AVERAGE ( 'calctable'[stress2] ) )
                ),
                IF (
                    SELECTEDVALUE ( webgraph[Category] ) = "Vertebraal",
                    AVERAGEX (
                        KEEPFILTERS ( VALUES ( 'calctable'[LastValue] ) ),
                        CALCULATE ( AVERAGE ( 'calctable'[Vert2] ) )
                    ),
                    0
                )
            )
        )
    )
)

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

amitchandak
Super User
Super User

@DionTN , Try a measure like

 

Gemiddelde van BodyComp2 per LastValue =
CALCULATE(AVERAGEX(VALUES('calctable'[LastValue]),
CALCULATE(AVERAGE('calctable'[BodyComp2]))
), allselected())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

I need to change the Kolom calculation cause that result is not correct where i expect 7.63.

 

Now I tried your example but it still gives 7.31:

Kolom =
IF (
    webgraph[Category] = "Lichaamssamenstelling",
    CALCULATE (
        AVERAGEX (
            VALUES ( 'calctable'[LastValue] ),
            CALCULATE ( AVERAGE ( 'calctable'[BodyComp2] ) )
        ),
        ALLSELECTED ()
    ),
    0
)

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors