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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
VKB
Frequent Visitor

DAX Alter One column data based on the duplicates in the other column

I have a scenario where I have an 'Accounts' table with four columns ( DB, AcctCode, AcctName, and ExpectedAcctCode ).
The problem is different 'AcctCode''s are there for the same 'AcctName' field.
The requirement is if there are multiple 'AcctCode's are there for the same 'AcctName', Min 'AcctCode' as per DB1 shall be returned in the 'ExpectedAcctCode' column.
Red colored fields are to be replaced with Yellow colored fields. 

This is the sample dataset for your convenience: https://drive.google.com/file/d/1iKD-MMGbNAKmJ99w1WyM5JoRB9Kr0r5u/view?usp=sharing

VKB_0-1681570873527.png

Thanks in advace!

Cheers!

VKB

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1681586427716.png

 

CNENFRNL_1-1681586495810.png

 

CNENFRNL_2-1681586560423.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Expected = calculate(min(Data[AcctCode]),filter(Data,Data[AcctName]=earlier(Data[AcctName])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1681586427716.png

 

CNENFRNL_1-1681586495810.png

 

CNENFRNL_2-1681586560423.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

MohammadLoran25
Super User
Super User

Hi @VKB ,

Try this:

Measuree =
CALCULATE (
    MIN ( Accounts[AcctCode] ),
    FILTER (
        ALL ( Accounts ),
        Accounts[AcctName] = SELECTEDVALUE ( Accounts[AcctName] )
    )
)

 

If this answer solves your problem, give it a thumbs up and mark it as an accepted solution so the others would find what they need easier.

Regards,
Loran

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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