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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AllanBerces
Post Prodigy
Post Prodigy

Containsstring and Count

Hi good day 

Can anyone help me on my calculated column, i have two table that connected. I want to count the number of Job.

AllanBerces_2-1760595378453.png

 

DESIRED OUTPUT

AllanBerces_3-1760595398185.png

 

Table Connection

AllanBerces_0-1760595134330.png

 

 JC Count =
CALCULATE(
    COUNTROWS(MAIN_DATA),
    FILTER(
        'MAIN_DATA',
        (CONTAINSSTRING('MAIN_DATA'[Job No.], "LP") || CONTAINSSTRING('MAIN_DATA'[Job No.], "LS") || CONTAINSSTRING('MAIN_DATA'[Job No.], "LI") || CONTAINSSTRING('MAIN_DATA'[Job No.], "LM"))
        &&
        NOT CONTAINSSTRING('MAIN_DATA'[Job No.], "QF")
        &&
        NOT CONTAINSSTRING('MAIN_DATA'[TQ], "SQ")
    )
)
 
Thank you
2 ACCEPTED SOLUTIONS

Sorry, I optimized the code.

View solution in original post

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

View solution in original post

17 REPLIES 17
Ahmedx
Super User
Super User

попробуй удалить ALL

L Count = 
VAR _KewSearch= SELECTCOLUMNS( {"LS","LP"},"KeyWord",[Value])
 VAR _Result = COUNTROWS(FILTER('MAIN_DATA TABLE','MAIN_DATA TABLE'[Code] in _KewSearch))
RETURN
_Result

Hi @Ahmedx thank you but show same, it count all not on the specific Main No.

try 

 

Hi @Ahmedx thank you for the reply but the new calculated column we required is for the current table.

AllanBerces_0-1760602455391.png

 

or creat new columns in Current

L = SUMX(RELATEDTABLE('MAIN_DATA TABLE'),[L-Count])
Q = SUMX(RELATEDTABLE('MAIN_DATA TABLE'),[Q-Count])

Post the file, I don't know what you have there.(current)

Hi @Ahmedx i have this column on my current table plus the new calculated column (L and Q Count)

AllanBerces_0-1760603957491.png

 

Thank you

Sorry, I optimized the code.

Hi @Ahmedx thnak you very much working perfectly

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

try

 

pls try

Q Count = 
VAR _KewSearch= SELECTCOLUMNS( {"QP","QF","QK","QL"},"KeyWord",[Value])
VAR _Cod = MAX('MAIN_DATA TABLE'[Main No])
 VAR _Result = COUNTROWS(FILTER(ALL('MAIN_DATA TABLE'),'MAIN_DATA TABLE'[Code] in _KewSearch&&'MAIN_DATA TABLE'[Main No]=_Cod))
RETURN
_Result
-----------------
L Count = 
VAR _KewSearch= SELECTCOLUMNS( {"LS","LP"},"KeyWord",[Value])
VAR _Cod = MAX('MAIN_DATA TABLE'[Main No])
 VAR _Result = COUNTROWS(FILTER(ALL('MAIN_DATA TABLE'),'MAIN_DATA TABLE'[Code] in _KewSearch&&'MAIN_DATA TABLE'[Main No]=_Cod))
RETURN
_Result

Hi @Ahmedx it work if i used measure but we required is calculated column to current table

AllanBerces_0-1760600503628.png

Thank you

Hi @Ahmedx can i use this as calculated column

Hi @Ahmedx thank you for the reply but it shows blank

Ahmedx
Super User
Super User

pls try

 

Hi @Ahmedx thank you for the reply but it count the overall instead of per Main No. Please note my MAIN DATA TABLE, Main No column has many different no.

AllanBerces_0-1760598758545.png

DESIRED OUTPUT

AllanBerces_1-1760598803060.png

Thank you

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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