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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
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.