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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

I would like to add custom column base on specific conditions

Hello, 
I have an Excel table that I want to import in the power query.  The sheet contains the orders that are received every month. and they are almost always the same. please have a look at the tables. 

Account nameSales amount MonthPriority level
Casey M454AprilLow
Shawn P665AprilHigh
Dafne l215AprilHigh
Kelly R154AprilLow
Vincent D255AprilMid
    
Casey M454MayLow
Shawn P100MayLow
Dafne l215MayHigh
Kelly R154MayHigh
Vincent D255MayMid
    
Casey M454JuneLow
Shawn P100JuneLow
Dafne l215JuneHigh
Kelly R154JuneLow
Vincent D255JuneMid

 

They are not always the same. Sales amount might change or priority level might change. I want to add a new custom column, that would add the value of "1" in the last month if there was a change to the same account name in the next month.
For example. In April, Shawn P's Priority was high but it changed to Low in May. I want to add value 1 to a new column in Shawn P's April Row

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to add a MonthSort column in Power Query Editor and then add a custom column.

vrzhoumsft_0-1696235259884.png

Custom Column:

let _Nextlevel = 
List.Max(
let 
_AccountName = [Account name],
_MonthSort = [MonthSort]
in
Table.SelectRows(#"Added Conditional Column", each _AccountName = [Account name] and [MonthSort] = _MonthSort+1)[Priority level])
in
if _Nextlevel <> null and [Priority level] <> _Nextlevel then 1 else null

Result is as below.

vrzhoumsft_1-1696235287399.png

 

Best Regards,
Rico Zhou

 

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

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to add a MonthSort column in Power Query Editor and then add a custom column.

vrzhoumsft_0-1696235259884.png

Custom Column:

let _Nextlevel = 
List.Max(
let 
_AccountName = [Account name],
_MonthSort = [MonthSort]
in
Table.SelectRows(#"Added Conditional Column", each _AccountName = [Account name] and [MonthSort] = _MonthSort+1)[Priority level])
in
if _Nextlevel <> null and [Priority level] <> _Nextlevel then 1 else null

Result is as below.

vrzhoumsft_1-1696235287399.png

 

Best Regards,
Rico Zhou

 

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

 

audreygerred
Super User
Super User

Rather than adding a column into the data, I would suggest creating a date in the fact table instead of just month and then adding a date table, then assigning the priority a numerical ranking (for example High = 1, Med = 2, Low = 3) through a dimension table and join. Next, I created a measure that compares the rank MoM, then have icons showing in the table rather than the change MoM%.

audreygerred_1-1695907347104.png

 

 





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

Proud to be a Super User!





Helpful resources

Announcements
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.