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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Power-CJ
Helper I
Helper I

SWITCH CASE - Using Array List for Conditional Calculation

Hello there,

i'm writing a Dax Measure in Order to do an conditional Calculating at the Item Ledger Entry of articles.

I have 3 amounts with article numbers to do a different calculation.

The Switch Case will proof the number and based on that the SUM of the Ledger Entry will be divided with 9, 11 or 15

 

Till now my Code is like this  

 

Measure = 

 SWITCH(
        SELECTEDVALUE( $Item Ledger Entry'[Item No_] ),
        // AMOUNT 1
        1060, DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 9 ),
        1060, DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 9 ),
        // AMOUNT 2        
        1102 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),
        1100 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),
        1099 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),
        1098 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),
        1093 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),  
        1092 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),    
        1091 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),    
        1078 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),
        1057 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 11 ),  
        // AMOUNT 3
         1078 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 15 ),
         1110 , DIVIDE( ABS( SUM( $Item Ledger Entry'[Stock] ) ), 15 ),
         BLANK()
    )
 
Now i'm plannin gto reduce line of Code by using Array-List variables like this:
 
    VAR _AMOUNT1 = {1060, 1061}
    VAR _AMOUNT2 = {1057, 1078, 1091, 1092, 1093, 1098, 1099, 1100, 1102}
    VAR _AMOUNT3 = {1078, 1110}
 
How can i check if the Item_No of the table Itme Ledger Entry is part of a array-List in order to the the specificant division?
1 ACCEPTED SOLUTION
tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @Power-CJ ,

 

Does the "IN" operator work in your case?

 

Here an example:

tackytechtom_0-1672321492443.png

 

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
Power-CJ
Helper I
Helper I

Hello Tom,

 

thanks for the quick Response.

 

There Where you placed 'Table'[Order] I only can place Measure and no Columns of Table.

 

But when i set the function SELECTEDVALUE() in front of the column it will work.

 

thanks a lot 

 

 

tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @Power-CJ ,

 

Does the "IN" operator work in your case?

 

Here an example:

tackytechtom_0-1672321492443.png

 

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors