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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. 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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.