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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
AxelKAp
Helper I
Helper I

Help to build new column with DAX

Hello, 

I have created a column to have a PO lines type, but sometimes people forget to fill some fields so I have some PO lines with a type "No Type", so I want that the line with "No type" takes the type of the other lines of the PO. I show you an example:

PO Number   Line         Comment                 PO Type       Final PO Type
123                   1        I have a quote                P2P                    P2P
123                   2        I have a quote                P2P                    P2P
123                   3             (blank)                      No Type             No type
234                   1        I don't have quote         S2P                      S2P
234                   2        I have quote                   P2P                     S2P

In the example I want to switch No Type with P2P. While knowing I calculate the column "PO Type" like that :

PO Type = IF(CONTAINSSTRING('pochannel-mastervendor'[Form Response],"Je n'ai pas de devis et souhaite un appel d'offre"), "S2P", IF(CONTAINSSTRING('pochannel-mastervendor'[Form Response],"J'ai un devis mais souhaite d'autres propositions"), "S2P", IF(CONTAINSSTRING('pochannel-mastervendor'[Form Response],"J'ai déjà un devis ou plusieurs devis"), "P2P", "No type")))

And the column "Final PO Type" like that :

Final PO Type =
var _POnb = 'pochannel-mastervendor'[PO Number (Header)]
var _list = FILTER('pochannel-mastervendor', 'pochannel-mastervendor'[PO Number (Header)] = _POnb)
Return
IF(CONTAINS(_list,'pochannel-mastervendor'[PO Type] , "S2P"), "S2P", 'pochannel-mastervendor'[PO Type])

Thanks for your help !

 
2 REPLIES 2
VahidDM
Super User
Super User

Hi @AxelKAp 

 

What @lbendlin pointed out is important, you need to add more details to your scenario.

BTW, if you need a new column to show the PO Type and replace NO Type with Final PO Type, use this:

PO Type sum = 
IF (
    [Final PO Type] = "No Type",
    MAXX (
        FILTER (
            'pochannel-mastervendor',
            'pochannel-mastervendor'[PO Number]
                = EARLIER ( 'pochannel-mastervendor'[PO Number] )
                && 'pochannel-mastervendor'[Final PO Type] <> "No Type"
        ),
        'pochannel-mastervendor'[Final PO Type]
    ),
    'pochannel-mastervendor'[Final PO Type]
)

 

Output:

VahidDM_0-1633485946260.png

 

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

Appreciate your Kudos!!

 

lbendlin
Super User
Super User

You need to decide what to do in the following scenarios

 

- none of the other PO line items has a PO Type either

- the other PO line items have different PO Types

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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