cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
ybicalways79
Frequent Visitor

DAX - Changing Between SUM and AVERAGE in a Matrix

Help!

 

I attempted multiple measures to get the results i need.  I can do either SUM or AVERAGE but not both.  Where am i going wrong?

 

ybicalways79_0-1687352572892.png

 

ybicalways79_1-1687352624173.png

 

FormatMetric OperationalSales =
VAR Val = SUM ( SalesData[Value] )      
RETURN      
    SWITCH (    
        SELECTEDVALUE ( SalesData[Attribute] ),
        "Overall Sales"FORMAT (Val, "$#,##0;($#,##0)" ),
        "Overall Conversion (%)"FORMAT (Val, "0.0%" ),
        "Overall Margin (%)"FORMAT (Val, "0.0%" ),
        "Overall Lookup (Ct.)"FORMAT (Val, "0" )
)
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @ybicalways79 
Please try

FormatMetric OperationalSales =
VAR Val =
    SUM ( SalesData[Value] )
VAR Ave =
    AVERAGE ( SalesData[Value] )
RETURN
    SWITCH (
        SELECTEDVALUE ( SalesData[Attribute] ),
        "Overall Sales", FORMAT ( Val, "$#,##0;($#,##0)" ),
        "Overall Conversion (%)", FORMAT ( Ave, "0.0%" ),
        "Overall Margin (%)", FORMAT ( Ave, "0.0%" ),
        "Overall Lookup (Ct.)", FORMAT ( Val, "0" )
    )

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @ybicalways79 
Please try

FormatMetric OperationalSales =
VAR Val =
    SUM ( SalesData[Value] )
VAR Ave =
    AVERAGE ( SalesData[Value] )
RETURN
    SWITCH (
        SELECTEDVALUE ( SalesData[Attribute] ),
        "Overall Sales", FORMAT ( Val, "$#,##0;($#,##0)" ),
        "Overall Conversion (%)", FORMAT ( Ave, "0.0%" ),
        "Overall Margin (%)", FORMAT ( Ave, "0.0%" ),
        "Overall Lookup (Ct.)", FORMAT ( Val, "0" )
    )

Thank you!  I was so close on this one!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors