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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
FeroSK
Frequent Visitor

AverageX with dynamic denominator

Hi Friends

 

My snowflake data model contains many-to-many relationships

FeroSK_0-1669553854275.png

This is intentional because I want to use multiple values from the fact table to calculate separate indicators.

I need to use AverageX because I need to divide each Indicator[Name] by the denominator given in the Indicator Details[Denominator] table

 

The problem is in the dynamic selection of the denominator according to the Denominator column in the Indicator detail table. Could someone help me solve this?

 

Thank you

FeroSK_0-1669566573489.png

 

with only one selected denominator:

FeroSK_0-1669635357955.png

 


PBIX to download 

 

 

 

 

Total Count = 
COUNTROWS( 'Fact Table' )
Average = 
    AVERAGEX(
        VALUES('Indicator Details'[Name]),
            [Total Count] /
            var _denominator = SELECTEDVALUE( 'Indicator Details'[Denominator] ) 
            var _denominatorValue = 
               SWITCH( 
                TRUE(),
                _denominator = "Measure A", [Denominator 1],
                _denominator = "Measure B", [Denominator 2],
                _denominator = "Measure C", [Denominator 3]
               )
            return
            _denominatorValue
    )

 

 

 

 

This is example only:

 

 

 

Denominator 1 = 10 
Denominator 2 = 20
Denominator 3 = 30

 

 

 

 

 

Indicator table:
IndicatorIndicator ID

Indicator 1Green
Indicator 2Blue/Pink
Indicator 2Blue
Indicator 2Blue/Yellow
Indicator 3Yellow
Indicator 3Yellow/Pink
Indicator 1Blue/Yellow

 

Indicator Details:

Indicator IDNameDenominator

GreenName1Measure A
GreenName2Measure A
GreenName3Measure B
BlueName4Measure A
BlueName5Measure A
BlueName6Measure A
Blue/PinkName7Measure B
Blue/PinkName8Measure B
Blue/PinkName9Measure C
Blue/YellowName10Measure B
Blue/YellowName11Measure B
YellowName12Measure C
YellowName13Measure A
Yellow/PinkName14Measure A
Yellow/PinkName15Measure B

 

4 REPLIES 4
FeroSK
Frequent Visitor

please, someone help

FeroSK
Frequent Visitor

sample PBIX is in first message

Greg_Deckler
Super User
Super User

@FeroSK One thought, try DISTINCT vs VALUES


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Sorry, did not help. Problem is in this denominator part:

            var _denominator = 
                LOOKUPVALUE( 
                    'Indicator Details'[Denominator], 
                    'Indicator Details'[Denominator], 
                    SELECTEDVALUE( 'Indicator Details'[Denominator] ) 
                )
            var _denominatorValue = 
               SWITCH( 
                TRUE(),
                _denominator = "Measure A", [Denominator 1],
                _denominator = "Measure B", [Denominator 2],
                _denominator = "Measure C", [Denominator 3]
               )
            return
            _denominatorValue

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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