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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
JeroenR
Helper V
Helper V

SUMX in dynamic Calculation Group

Hi all,

 

I have the following measure which I would like to place in a calculation group so that I do not need to recreate this for each measure I want to use it. 

The following measure I use to calculate an average/ index 

 

 

_IndexMeasure = 
VAR _Months =
    CALCULATE ( DISTINCTCOUNT ( 'Date'[Month Year Long] ), REMOVEFILTERS () )
VAR _Index =
    CALCULATE (
        SUMX ( 'Table1', 'Table1'[Value %] ),
        REMOVEFILTERS ( 'Date'[Month Year Long] )
    )
RETURN
    DIVIDE ( _Index, _Months )

 

 


Now I want to put this in an calulated column, and I would expect that I need to do the same things as if you want to implement it as a regular measure, so;

 

 

VAR _Months =
    CALCULATE ( DISTINCTCOUNT ( 'Date'[Month Year Long] ), REMOVEFILTERS () )
VAR _Index =
    CALCULATE (
        SUMX ( SELECTEDMEASURE() ),
        REMOVEFILTERS ( 'Date'[Month Year Long] )
    )
RETURN
    DIVIDE ( _Index, _Months )

 

 

But this does not work, because SUMX() needs 2 parameters. But how can I make this dynamic so that I can use the exact same functionality for other columns/ tables as well?

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Why do you need the SUMX? I would try it with just

 

CALCULATE(SELECTEDMEASURE(), ...

 

Pat

 

Microsoft Employee

View solution in original post

2 REPLIES 2
ppm1
Solution Sage
Solution Sage

Why do you need the SUMX? I would try it with just

 

CALCULATE(SELECTEDMEASURE(), ...

 

Pat

 

Microsoft Employee

Thank you, this works as well. 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors