Forum Discussion

Saxon10's avatar
Saxon10
Icon for Post Prodigy rankPost Prodigy
5 years ago
Solved

COUNTROW based on the Text

  Hi,   The same item has the following sales code from 9001 to 9010 and DMK in data table but I am intersted the following codes only "9001,9002,9003,9004"   if same item has the following sale...
  • v-yalanwu-msft's avatar
    5 years ago

    Hi, Saxon10 ,

     

    You could create measure and column by the following formula:
    Step1:create a column

    WITHITEM = SWITCH(TRUE(),[SALES CODE] in {"9001","9002","9003","9004"},"NOT OKAY",[SALES CODE]<>BLANK(),"OKAY")

    And if you want to COUNTROW based on the Text:

    count = CALCULATE(COUNTROWS('DATA'),FILTER(ALLEXCEPT('DATA','DATA'[ITEM]),[SALES CODE] in{"9001","9002","9003","9004"}))

    The final output is shown below:

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.