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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

New calculated column with If condition between two fields

Hi Power BI user,

 

I'm facing a problem with a calculated column with the following criteria:

 

Example.png

I have two fields, "Code" and "Allocation", a code have an allocation that can be 1 or 2, sometimes a code can be 1 and 2. I would like to create a new calculated column that write 1_2 if a code is 1 and 2. I think that the only way is to create a if + lookup condition but I'm not sure how to define it.

 

Any suggestions?

 

Thank you in advance.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Perhaps:

 

Calculated Column = 
  VAR __Table = FILTER('Table',[Code] = EARLIER([Code]))
RETURN
  CONCATENATEX(__Table,[Allocation],"_")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Perhaps:

 

Calculated Column = 
  VAR __Table = FILTER('Table',[Code] = EARLIER([Code]))
RETURN
  CONCATENATEX(__Table,[Allocation],"_")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Greg thank you very much for the support, however i'm facing with a new problem. The dax formule work fine but i noticed that sometimes the codes are repeated more and more times, so I have also concatenated the other  allocation, like 1_1, or 3_3_3 . I would only recognize the code with id 1 and 2 and keep them just one time. Any suggestion?

Anonymous
Not applicable

Thank you very much for the solution, it works perfect!

dobregon
Impactful Individual
Impactful Individual

try something like this

New Column = 
Var a = CONCATENATEX (
    SUMMARIZE (
        FILTER ( Table, Table[Code] = Table[Code]  ),
        Table[Allocation] 
    ),
    Table[Allocation]  ,
    "_"
)
return
if(ISBLANK(a),"Not defined", a)


Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors