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
dhanekula1996
Helper I
Helper I

Reg: Switch function and Totals

Hello all,
 I am trying to create a measure which shows values based on the condition. My code is working fine but my dax is not showing the total of the column. Can you please suggest me what change I need to do my code inorder to get Total of the column.
@Greg_Deckler @OpenDataLab @ValtteriN @amitchandak 
Dax Command:

Relative Cost =
IF(
HASONEVALUE('Dimensions'[ECT Value]),
SWITCH( VALUES('Dimensions'[ECT Value]),
42,[Annual Cost  ($0.76)]
51,[Annual Cost ($0.80)],
48,[Annual Cost ($0.85)],
61,[Annual Cost ($0.92)]
)
)

switch 1.PNG


1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Is this what you're after?

Relative Cost =
SUMX (
    VALUES ( 'Dimensions'[ECT Value] ),
    SWITCH (
        'Dimensions'[ECT Value],
        42, [Annual Cost  ($0.76)],
        51, [Annual Cost ($0.80)],
        48, [Annual Cost ($0.85)],
        61, [Annual Cost ($0.92)]
    )
)

View solution in original post

2 REPLIES 2
dhanekula1996
Helper I
Helper I

Exactly!!! Thank you @AlexisOlson. This works perfect!!

AlexisOlson
Super User
Super User

Is this what you're after?

Relative Cost =
SUMX (
    VALUES ( 'Dimensions'[ECT Value] ),
    SWITCH (
        'Dimensions'[ECT Value],
        42, [Annual Cost  ($0.76)],
        51, [Annual Cost ($0.80)],
        48, [Annual Cost ($0.85)],
        61, [Annual Cost ($0.92)]
    )
)

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.