Reply
kd_pandey
Regular Visitor
Partially syndicated - Outbound

IF and Statement in Excel Power Query

I am trying to create below scenario in excel power query, where I'm getting when trying to create Point. 2 & 3

kd_pandey_0-1720616232212.png

 

table as below

 

TypeAmount_AAmount_BAmount_C
New8921  
Renew3703  
Renew427  
Renew7379  
Renew3148  
Renew787  
New2437  
New6799  
  15440
  79120
  96100
New2513  
New7962  
Renew4483  
Renew1296  
Renew4438  
Renew3202  
  07922
  01413
  04167
  05959
  06227
New843  
New6560  
New7359  
Renew5718  
  00
  00
  10971682
  5991133
New3569  
New3899  
New4583  
New7713  
New2874  
New2938  
1 ACCEPTED SOLUTION

Syndicated - Outbound

in the example data you gave the Amount_A values were null.

Changed the code so it works with = 0 too 🙂

if [Amount_A] = null or [Amount_A] = 0  then
    if [Amount_C] = null or [Amount_C] = 0 then
        if [Amount_B] = 0 or [Amount_B] = null

              then null
              else "Expiring"
       else "Renewed"
else [Type]

View solution in original post

6 REPLIES 6
BenjaminSNN
Frequent Visitor

Syndicated - Outbound

I think this should do the trick. Add a new custom column with the following code:

if [Amount_A] = null then
    if [Amount_C] = null or [Amount_C] = 0 then
        if [Amount_B] = 0 or [Amount_B] = null

              then null
              else "Expiring"
       else "Renewed"
else [Type]


Tip: Basing logic on the False premise (C <> 0) often makes things more complicated. Try to build your logical from the true (C = 0) premise

BiAnalyst
Resolver I
Resolver I

Syndicated - Outbound

You will have to add another custome column in Powerqueryas following,
= if [Type] <> null and [Type] <> "" then [Type]
else if [Amount C] <> 0 or [Amount C] <> null then "Renewed"
else if ([Amount B] = 0 or [Amount B] = null) and ([Amount C] = 0 or [Amount C] = null) then ""
else "Expiring"

Please accept it as solution if works.

Syndicated - Outbound

this is the result of both solutions .. expring is missing in both 

kd_pandey_1-1720620251084.png

 

Syndicated - Outbound

in the example data you gave the Amount_A values were null.

Changed the code so it works with = 0 too 🙂

if [Amount_A] = null or [Amount_A] = 0  then
    if [Amount_C] = null or [Amount_C] = 0 then
        if [Amount_B] = 0 or [Amount_B] = null

              then null
              else "Expiring"
       else "Renewed"
else [Type]

Syndicated - Outbound

my bad .. I changed it to 0 in last moment while uploading to make it more simple which missed your first line of code.. thank you so much 

 

Syndicated - Outbound

Glad I could help!

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)