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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Ltice59
Frequent Visitor

Need help : comment compter avec conditions sur une partie de la référence

Bonjour

Je débute sur Power BI et dans une table j'ai un très grand nombre de structures référencées par des codes de 3 types distincts :

A +9 chiffres - F+4 chiffres - 5 chiffres

Je souhaite créer 3 mesures qui me permettront de les répartir en 3 catégories :

Association - structure - client

Je pensais à une formule du type : Association = calculate(count(pernoass ....

mais je ne sais pas comment inclure une condition prenant en compte que la 1ère lettre de la référence

 

Exemple de données

A075000115

A001254017

F9801

F0012

12306

45203

 

Merci pour votre aide

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Ltice59 ,

You can create a calculated column as below to get it, please find the details in the attachment.

Column = 
SWITCH (
    TRUE (),
    LEFT ( 'Table'[Data], 1 ) = "A"
        && LEN ( 'Table'[Data] ) = 10, "Association",
    LEFT ( 'Table'[Data], 1 ) = "F"
        && LEN ( 'Table'[Data] ) = 5, "Structure",
    IFERROR ( VALUE ( 'Table'[Data] ), BLANK () )
        && LEN ( 'Table'[Data] ) = 5, "Client",
    BLANK ()
)

yingyinr_0-1669023397695.png

Best Regards

Community Support Team _ Rena
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

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @Ltice59 ,

You can create a calculated column as below to get it, please find the details in the attachment.

Column = 
SWITCH (
    TRUE (),
    LEFT ( 'Table'[Data], 1 ) = "A"
        && LEN ( 'Table'[Data] ) = 10, "Association",
    LEFT ( 'Table'[Data], 1 ) = "F"
        && LEN ( 'Table'[Data] ) = 5, "Structure",
    IFERROR ( VALUE ( 'Table'[Data] ), BLANK () )
        && LEN ( 'Table'[Data] ) = 5, "Client",
    BLANK ()
)

yingyinr_0-1669023397695.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ltice59
Frequent Visitor

Merci pour votre aide ,

je vais tester cette solution qui correspond tout à fait au cas des associations

mais comment faire pour mes réferences qui ont toutes 5 caractères (soit 5 chiffres, soit 1 lettre suivi de 4 chiffres)?

 

The LEN formula takes into consideration the number of characters inside the value, regardless of the type of character, so LEN(A5022) = 5 because there are 5 characters in that value.

 

Please dont forget to accept this as a solution if it solved your issue 🙂

 

Merci

MAwwad
Super User
Super User

Salut,

 

You can try the IF Function with the LEN

 

Logic like IF(LEN(Value) = 10, then return Association.

 

If value has length of the 10charachters then to return "Association"

 

 

Thanks

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.