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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
suman-petlu
Frequent Visitor

How to create measure columns using case statement based on condition in power bi

Hi all,

I am new to power bi,please let me know how to execute below case statement

CASE
WHEN t3189.w_xact_type_code = 'Standard Invoice' THEN
t4720.loc_exchange_rate * t4720.net_amt
WHEN t3189.w_xact_type_code = 'Invoice Cancellation' THEN
t4720.net_amt * - 1 * t4720.loc_exchange_rate
END

Thanks in advance
Suman
1 ACCEPTED SOLUTION

Hi,

 

Please try IF dax function:

Column = IF(RELATED('Table 2'[Date].[Year])=2000,'Table'[Amount]*'Table'[Quantity])

And it shows:

41.PNG

Hope this helps.

 

Best Regards,

Giotto Zhi

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

The above solution will help.

Also Refer :

https://docs.microsoft.com/en-us/dax/switch-function-dax

https://community.powerbi.com/t5/Desktop/Help-with-SWITCH-TRUE-with-multiple-items-to-evaluate/td-p/...

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
az38
Community Champion
Community Champion

Hi @suman-petlu 

try

Column = SWITCH([t3189.w_xact_type_code],
"Standard Invoice", [t4720.loc_exchange_rate] * [t4720.net_amt],
"Invoice Cancellation" ,- 1 *[t4720.net_amt] *  [t4720.loc_exchange_rate],
0
)

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 ,

 I tried using Switch function but i didn't get desried results.Please help

 

Capture.JPG

But tried to multiply with Constant value ,its working as expected

 

Capture1.JPG

Regards,

Suman

Hi,

 

Please try IF dax function:

Column = IF(RELATED('Table 2'[Date].[Year])=2000,'Table'[Amount]*'Table'[Quantity])

And it shows:

41.PNG

Hope this helps.

 

Best Regards,

Giotto Zhi

Try using this inside switch sumx(sales[Amount_sold]*sales[Quantity_sold])

 

Switch(times[calenderyear]="2000",sumx(sales[Amount_sold]*sales[Quantity_sold]))

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.