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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Replace character when not in a word

Hello all,

 

This issue has had me going for a few hours now so am turning to the smarter brains of this forum 🙂

 

I have a column named "discipline" that can contain up to 9 characters along a drawing reference, in the following format:

 

DrawingDiscipline
WG1234A
WG 125A, C
WG 9090A, C, E, J, K, M, P, S, T
WG 087E

 

The letterts A, C etc cannot be changed in the raw database so I have to import them as is but I'd like to convert A to Architectural, C to Civil, E to Electrical, etc... for the purpose of filtering (I'd actually like to keep the Discipline column as it is)

 

The intent being that I then have a slicer with the listing of Architectural, Civil, Electrical and if I select Architectural, it will show in my table all drawings that have A in the Discipline( in the example above that is WG1234, WG 125 and WG 9090)

 

I have obviously tried to replace values sequentially in power query mode but I end-up with gibberish (A becomes ARCHITECTURAL, but then if E becomes ELECTRICAL I end-up with ARCHITELECTRICALCTURAL...). I have thought of unpivoting the data but I already have a couple million rows and it wouldn't be sustainable.


Any clever solution you can suggest?

 

Thanks in advance.

OF

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@Anonymous

 

Or in fact a leaner version:

 

MeasureNumDisplayedDrawings2_V2 =
COUNTROWS (
    FILTER (
        'All Documents';
        SUMX (
            FilterTableDiscipline;
            FIND ( FilterTableDiscipline[Discipline]; 'All Documents'[Discipline]; 1; 0 )
        )
            > 0
    )
)

Code formatted with   www.daxformatter.com

View solution in original post

24 REPLIES 24
AlB
Community Champion
Community Champion

@Anonymous

 

Quick solution. Probably not the most elegant. Unfortunately SUMMARIZECOLUMNS( ) seems not to be fully supported in a modified filter context yet so that's a drag. We thus cannot use the earlier approach that invokes [Discipline (Measure)], which would be waaay smoother. With some more work we might find a solution for that and get something more elegant but this should do:

 

 

MeasureNumDisplayedDrawings2 = 
COUNTROWS (
    FILTER (
        'All Documents';
        VAR CurrentDiscipline = 'All Documents'[Discipline]
        VAR CountOfDisciplines =
            SUMX (
                FilterTableDiscipline;
                MIN (
                    FIND ( FilterTableDiscipline[Discipline]; CurrentDiscipline; 1; BLANK () );
                    1
                )
            )
        RETURN
            IF ( CountOfDisciplines > 0; 1 )
            = 1
    )
)

 

Code formatted with   www.daxformatter.com

AlB
Community Champion
Community Champion

@Anonymous

 

Or in fact a leaner version:

 

MeasureNumDisplayedDrawings2_V2 =
COUNTROWS (
    FILTER (
        'All Documents';
        SUMX (
            FilterTableDiscipline;
            FIND ( FilterTableDiscipline[Discipline]; 'All Documents'[Discipline]; 1; 0 )
        )
            > 0
    )
)

Code formatted with   www.daxformatter.com

Anonymous
Not applicable

@AlB, I have no idea what you've done, but it works perfectly.

 

Thank you very very much, I really appreciate your help.

AlB
Community Champion
Community Champion

@Anonymous

You're very welcome. Cool to hear it finally works.

The logic behind this last measure is very similar to that of the previous one. We merrily step through the 'All documents' table and, for each row, we check whether any of the disciplines selected in the slicer can be found within the Disciplines for the drawing. If so, we've found one drawing of interest and we include that row in the total count.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors