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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Help in nested if statement in a new column

Hi all,

I am new to Power BI and want to write a calculation using following columns

Quantity on hand , Po on order and YTD average sales and  Shipping Date  which are direct column from table.

The calculation should work like

If shipping date in data set is not null, then calculation should be:

  • Cal=Quantity on hand+ Current order/YTD average sales

Else the calculation should be:

  • Cal=Quantity on hand+ /YTD average sales

Also if Quantity on hand, Po on order and YTD average sales is null then Cal=0

I am unable to get null function in this calculation. 

Any suggestions what am i missing.

1 ACCEPTED SOLUTION
Arul
Super User
Super User

@Anonymous ,

check if this code helps or not,

Cal = 
SWITCH (
    TRUE (),
    'Table'[Shipping Date] <> BLANK (), 'Table'[Quantity on hand] + 'Table'[YTD average sales],
    'Table'[Quantity on hand] = BLANK ()
        || 'Table'[Po on order] = BLANK ()
        || 'Table'[YTD average sales] = BLANK (), 0,
    'Table'[Quantity on hand] + 'Table'[YTD average sales]
)

Arul_0-1676978756248.png

Thanks,

Arul

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


View solution in original post

1 REPLY 1
Arul
Super User
Super User

@Anonymous ,

check if this code helps or not,

Cal = 
SWITCH (
    TRUE (),
    'Table'[Shipping Date] <> BLANK (), 'Table'[Quantity on hand] + 'Table'[YTD average sales],
    'Table'[Quantity on hand] = BLANK ()
        || 'Table'[Po on order] = BLANK ()
        || 'Table'[YTD average sales] = BLANK (), 0,
    'Table'[Quantity on hand] + 'Table'[YTD average sales]
)

Arul_0-1676978756248.png

Thanks,

Arul

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.