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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
NickProp28
Post Partisan
Post Partisan

Coding checking and request help to multiple to value

Dear Community, 

 

I have two table and applied lookupvalue to get the information.

Condition:
If Unit is KG or LB, vlookup and return the KG rate.

If Unit is M3 or CF, vlookup and return the M3 rate.

Am I right if the DAX code is in this way? Just want double confirm on it

KG/M3 = Switch(True(),
(Main[Unit]= "KG" || Main[Unit] = "LB") , LOOKUPVALUE(Table1[Rate],Table1[From_Unit],Main[Unit],Table1[To_Unit],"KG"),

(Main[Unit] ="M3" || Main[Unit] = "CF") , LOOKUPVALUE(Table1[Rate],Table1[From_Unit],Main[Unit],Table1[To_Unit],"M3"),
BLANK())

Furthermore, I would like to modify the DAX code (No idea how to apply to calculation after the conditional statement). Instead showing the rate, I want the final calculation of multiply rate and quatity.

Expected value:

QuantityUnitKG/M3
125.2KG125.2
1023.1LB464.070
33M333
1234CF34.943
0KG0
0LB0
0M30
0CF0

 

Could you please have a look at this pbix: https://ufile.io/mfspjog4

Appreciated any help provided. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @NickProp28 ,

You can update the formula of your calculated column [KG/M3] as below, the part with red font is new added:

KG/M3 =
SWITCH (
    TRUE (),
     ( Main[Unit] = "KG"
        || Main[Unit] = "LB" ),
        LOOKUPVALUE (
            Table1[Rate],
            Table1[From_Unit], Main[Unit],
            Table1[To_Unit], "KG"
        ) * 'Main'[Quantity],
     ( Main[Unit] = "M3"
        || Main[Unit] = "CF" ),
        LOOKUPVALUE (
            Table1[Rate],
            Table1[From_Unit], Main[Unit],
            Table1[To_Unit], "M3"
        ) * 'Main'[Quantity],
    BLANK ()
)

rate multiply quanitity..JPG

Best Regards

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@NickProp28 , Are you trying move data from one table to another?

Check if this video can help how to do -https://www.youtube.com/watch?v=czNHt7UXIe8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Dear @amitchandak ,

 

No Sir, 

I want to include the calculation part in SWITCH after return the rate. 

For example, 

(Main[Unit]= "KG" || Main[Unit] = "LB") , LOOKUPVALUE(Table1[Rate],Table1[From_Unit],Main[Unit],Table1[To_Unit],"KG"), Quantity * KG/M3 

 * I know can simply open another new column and perform the calculation. But would like to ask is it possible to do it in SWITCH.

Anonymous
Not applicable

Hi @NickProp28 ,

You can update the formula of your calculated column [KG/M3] as below, the part with red font is new added:

KG/M3 =
SWITCH (
    TRUE (),
     ( Main[Unit] = "KG"
        || Main[Unit] = "LB" ),
        LOOKUPVALUE (
            Table1[Rate],
            Table1[From_Unit], Main[Unit],
            Table1[To_Unit], "KG"
        ) * 'Main'[Quantity],
     ( Main[Unit] = "M3"
        || Main[Unit] = "CF" ),
        LOOKUPVALUE (
            Table1[Rate],
            Table1[From_Unit], Main[Unit],
            Table1[To_Unit], "M3"
        ) * 'Main'[Quantity],
    BLANK ()
)

rate multiply quanitity..JPG

Best Regards

Hi @NickProp28 ,

I have checked your file. And you can use switch.

I created two new columns without switch or if and they giving values as an individual, which gets merged because of the switch in your column.

At a high level, the approach seems fine. Unless there some issue you are facing.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.