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

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

Reply
Anonymous
Not applicable

switch with different table columns in power bi

Hi all,
I Have two tables

one is dProduct  and other fStock_line
in dProduct I want to create a calculated Col that do a switch() statment and I have dificult to get information from fStock_line
my code is the follow :

Priority = SWITCH( TRUE(), SELECTEDVALUE( fStock_line[S_STOCK]) = 0 , "1" , SELECTEDVALUE( fStock_line[S_STOCK]) > 0 , "2" ,
SELECTEDVALUE( fStock_line[S_STOCK]) < 0 , "3" , "0")
As result give me all column with "1"(first condition, what is wrong)
1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

You need to change your calculated column to measure to display dynamically. 

Like this:

Priority =
SWITCH (
    TRUE (),
    MAX ( dProduct[QtyMin] ) <> "NULL"
        && SELECTEDVALUE ( fStock[SV_STOCK] ) = 0, 1,
    MAX ( dProduct[QtyMin] ) <> "NULL"
        && SELECTEDVALUE ( fStock[SV_STOCK] ) > 0, 2,
    MAX ( dProduct[QtyMin] ) <> "NULL"
        && SELECTEDVALUE ( fStock[SV_STOCK] )
            < MAX ( dProduct[QtyMin] ) / 2, 3,
    0
)

 

Best Regards,

Community Support Team _Janey

If this post helps, then please consider Accept it as the solution to help the other members find it more.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I would like to add more information

I have these two tables TABULAR Model.

dProduct

Code                   PNM                    RefNumber        QtyMin

105949               105826               601C3103                 1     
110115               66697                 1700639                   1     

111894               54576                 4952826                    2    

114257               104692               4505005B                  0    

664405               49464                 65B89696               NULL

664406               71089                 2092D                     NULL


fStock

dProductcode   PNM                                   SV_STOCK

111894                54576                                              0

114257                67934                                              0

110115                66697                                              1

111894                54576                                              2


I try to do a switch condition between these two tables


like the follow condition
Priority = SWITCH(TRUE(),
dProduct [QtyMin]<>"NULL" && SELECTEDVALUE(fStock[SV_STOCK])= 0 , 1,

dProduct[QtyMin]<>"NULL" && SELECTEDVALUE(fStock[SV_STOCK]) > 0 , 2,

dProduct [QtyMin]<>"NULL" && SELECTEDVALUE(fStock[SV_STOCK] < dProduct [QtyMin]/2 , 3,

0)

Hi, @Anonymous 

 

You need to change your calculated column to measure to display dynamically. 

Like this:

Priority =
SWITCH (
    TRUE (),
    MAX ( dProduct[QtyMin] ) <> "NULL"
        && SELECTEDVALUE ( fStock[SV_STOCK] ) = 0, 1,
    MAX ( dProduct[QtyMin] ) <> "NULL"
        && SELECTEDVALUE ( fStock[SV_STOCK] ) > 0, 2,
    MAX ( dProduct[QtyMin] ) <> "NULL"
        && SELECTEDVALUE ( fStock[SV_STOCK] )
            < MAX ( dProduct[QtyMin] ) / 2, 3,
    0
)

 

Best Regards,

Community Support Team _Janey

If this post helps, then please consider Accept it as the solution to help the other members find it more.

selimovd
Super User
Super User

Hey @Anonymous ,

 

do you want the column to be dynamic?
Because this is not possible, calculated columns are always static and don't have a filter context. So the SELECTEDVALUE won't work in a calculated column.

 

If you give more information I can try to help you to get the result you want.

If you need any help please let me know.

 

If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up.
Best regards
Denis

 

Anonymous
Not applicable

Hi Denis,
yes I would like do the column dynamic 
thanks,
peter

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors