Forum Discussion

RaedHussein's avatar
RaedHussein
New Member
5 years ago
Solved

Count item names

Hey everyone

I Have a selling table that every time I sell an item it updated new row with the item name and selling price and some other columns, I want make a new table that contains 2 columns one for the item name and the other COUNT number of this item from selling table, how can I do that

  • IN DAX, create a new table 

     

    NEW_TABLE = SUMMARIZE(TABLE_NAME,
                                                 ITEM_COLUMN_NAME,
                                                 "UNITS_SOLD", COUNTROWS(TABLE_NAME)
                                                  )
     
    You can do it with Power Query too

6 Replies

  • AlB's avatar
    AlB
    Community Champion

    Hi RaedHussein 

    You can do this in PQ (Group By) or DAX (ADDCOLUMNS). Which one do you need?

    Can you provide a sample of your initial table as example?

     

    Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

     

    • RaedHussein's avatar
      RaedHussein
      New Member

      Hi AIP, thanks for helping.

      I Prefer Dax.

      I hope you can help with all I need>>

      let us say I have these 2 tables on an Excel file


      The first table on the right is for calculating the cost for every item depending on the kind of material

      And the second table on the left is for sold items with details of the buyer.

      I need to calculate the material cost of sold items for each product, in a way that I can use a filter to know the cost of each material.

      So there are products costs and materials costs of sold product 





      • AlB's avatar
        AlB
        Community Champion

        RaedHussein 

        Can you share the tables in an Excel file so that the contents can be readily copied? You can upload a file by sharing the URL to the file hosted elsewhere: Dropbox, Onedrive... or just upload the file to a site like tinyupload.com (no sign-up required).

         

        Plus can you show an example of the output that you are looking for, be it in a table or in a visual?

         

        Do not mark the question solved until it actually is.

         

        Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

        Contact me privately for support with any larger-scale BI needs, tutoring, etc.

         

  • IN DAX, create a new table 

     

    NEW_TABLE = SUMMARIZE(TABLE_NAME,
                                                 ITEM_COLUMN_NAME,
                                                 "UNITS_SOLD", COUNTROWS(TABLE_NAME)
                                                  )
     
    You can do it with Power Query too
  • AlB Many thanks, this is my first time I used to ask, I won't next time >>

    Yes Sure, but most of the cells is in the Arabic language except the header of columns 

    this is the link
     https://www.dropbox.com/scl/fi/5mp76qw64ykninmxk3e2v/Birwaz-test-1-Copy.xlsx?dl=0&rlkey=8e9lamfhy7807ea1o5740opji

    and this is a sample of what I am trying to do 

    The first visual on the left contains a number of selling the item and its revenue, the second one on the right calculates the profit depending on revenue - material cost.. it's work on the visual but not on the card, because the measure need corrections in filtering I guess so