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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.