+ Reply to Thread
Results 1 to 7 of 7

Dax CountRows

  1. #1
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Question Dax CountRows

    Hi All,

    I have a dax model, where I identify new users marked as "1" in a field.
    The new user identification appears only one time to those records which consists new users first time in the model.
    e.g. for a given period the data as follows:
    User A - 0
    User A - 0
    User A - 0
    User B - 1
    User B - 0
    User A - 0
    User A - 0
    User A - 0
    User B - 0
    User A - 0
    User C - 1
    User C - 0

    In the above data "User A" does not qualify as a new user as he was an old user from previous period. But users "B" & "C" are new users in the given period.
    I want to create a measure which calculates "countrows" of new users in the given period.
    Expected results:
    zero for User A
    3 for User B
    2 for User C

    Any help is appreciated.

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,659

    Re: Dax CountRows

    I will be interested to see how/if this can be done using DAX.
    In the meantime here is how it might be handled using a normal pivot table.
    1. Add a column to the source data: =IF(B2=1,1,IFERROR(IF(VLOOKUP(A2,A$1:B1,2,0)=1,1,0),""))
    2. Pull the field for the new column into the values area and summarize values by Sum
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Dax CountRows

    @JeteMc Thanks for your reply.
    Unfortunately, I am unable to create a helper field in the database, its huge, and might slow down my model.
    Let us see if anyone can come up a Dax measure for this.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,659

    Re: Dax CountRows

    As you already have a Dax model, according to post #1, it may help if you could attach a sample file to your post.
    Information regarding attachments is in the "HOW TO ATTACH YOUR SAMPLE WORKBOOK" banner at the top of the page.

  5. #5
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Dax CountRows

    I don't think it can add any value.
    The subject calculation is withing the following three Fields:
    User ID (A, B, C, etc)
    NewUser (1, 0)
    Date

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,280

    Re: Dax CountRows

    You could use a measure like:

    =VAR NewUsers = SELECTCOLUMNS(FILTER(Table1,Table1[New]=1),"User",Table1[User])
    RETURN CALCULATE(COUNTROWS(Table1),NewUsers)
    Remember what the dormouse said
    Feed your head

  7. #7
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Dax CountRows

    Thanks, that was so easy in the end

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Countrows help
    By dblackwood72 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-16-2021, 01:00 PM
  2. DAX - calculate % of Grand Total using COUNTROWS
    By _eNVy_ in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 04-03-2020, 05:17 AM
  3. Excel DAX Countrows with to
    By Hassan1977 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-22-2017, 12:24 PM
  4. [SOLVED] countrows
    By KBSH in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2017, 11:45 AM
  5. [SOLVED] [SOLVED] Help with Countrows functionality within a Macro
    By Pank in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-11-2005, 03:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1