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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DivakarKrishnan
Helper II
Helper II

SWTICH DAX Rewrite

Dear Team,

 

I have one DAX formula which is bit slow and it's not written in proper way, and I would like to rewrite this DAX code in some efficient way. Can someone assist me to rewrite this code please?

 

DAX 

 

Select =
SWITCH (
    MIN ( 'z III version selection'[slectionnum] ),
    1,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 1,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    2,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 2,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    3,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 3,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    4,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 4,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    5,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 5,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    6,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 6,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    7,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 7,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    8,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 8,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    9,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 9,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    10,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 10,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        ),
    11,
        CALCULATE (
            [TotalAmount],
            Azdan_data[Scenario] = "Budget",
            'Azdan_data'[Version lookup] = 11,
            LEFT ( Azdan_data[Account Code], 3 ) <> "414"
        )
)

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@DivakarKrishnan 

Select =
var __min =  MIN ( 'z III version selection'[slectionnum] ) return

CALCULATE (
    [TotalAmount],
    Azdan_data[Scenario] = "Budget",
    'Azdan_data'[Version lookup] = __min,
    LEFT ( Azdan_data[Account Code], 3 ) <> "414"
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn



Try this please: 


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

1 REPLY 1
Fowmy
Super User
Super User

@DivakarKrishnan 

Select =
var __min =  MIN ( 'z III version selection'[slectionnum] ) return

CALCULATE (
    [TotalAmount],
    Azdan_data[Scenario] = "Budget",
    'Azdan_data'[Version lookup] = __min,
    LEFT ( Azdan_data[Account Code], 3 ) <> "414"
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn



Try this please: 


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.