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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
stribor45
Post Prodigy
Post Prodigy

Summary and Ranking

This code works for me as is but I would like to narrow it down based on the date. When I try to add another condition to the filter which is Table_A[Call Date] IN DATESBETWEEN "date1" and date1"  I get the error "single value for date can't be determined.  I feel like this has something to do with row context. How would I add that condition as well to my existing code?

 

 

 

 

DEFINE
    VAR REPS =
      FILTER (
        ADDCOLUMNS (
            SUMMARIZE (
                FILTER (
                    'Table_A',
                    'Table_A'[Name] <> "N/A"
                ),
                'Table_A'[Name]
            ),
            "@count", CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
            "@rank",
                RANKX (
                    ALL ( 'Table_A'[Name] ),
                    CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
                    ,
                    DESC,
                    DENSE
                )
        ), //addcolumns
        [@rank] = 1 || [@rank] = 2 )
      
       
EVALUATE
REPS

 

 

4 REPLIES 4
Anonymous
Not applicable

Hi @stribor45 ,

 

Please try:

If you need a date range:

DEFINE
    VAR _date1=DATE(2023,1,1)  //You can change this date variable to suit your needs
    VAR _date2=DATE(2023,1,3)  ////You can change this date variable to suit your needs
    VAR REPS =
      FILTER (
        ADDCOLUMNS (
            SUMMARIZE (
                FILTER (
                    'Table_A',
                    'Table_A'[Name] <> "N/A"
                  && 'Table_A'[Call Date] IN DATESBETWEEN('Table_A'[Call Date],_date1, _date2)
                ),
                'Table_A'[Name]
            ),
            "@count", CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
            "@rank",
                RANKX (
                    ALL ( 'Table_A'[Name] ),
                    CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
                    ,
                    DESC,
                    DENSE
                )
        ), //addcolumns
        [@rank] = 1 || [@rank] = 2 )
      
       
EVALUATE
REPS

vtangjiemsft_1-1706498003316.png

 

If you need to equal a single date:

DEFINE
    VAR _date1=DATE(2023,1,1)  //You can change this date variable to suit your needs

    VAR REPS =
      FILTER (
        ADDCOLUMNS (
            SUMMARIZE (
                FILTER (
                    'Table_A',
                    'Table_A'[Name] <> "N/A"
                  && 'Table_A'[Call Date] =_date1
                ),
                'Table_A'[Name]
            ),
            "@count", CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
            "@rank",
                RANKX (
                    ALL ( 'Table_A'[Name] ),
                    CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
                    ,
                    DESC,
                    DENSE
                )
        ), //addcolumns
        [@rank] = 1 || [@rank] = 2 )
      
       
EVALUATE
REPS

 

vtangjiemsft_0-1706497900139.png

 

Best Regards,

Neeko Tang

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

This works but I noticed that is N/A somehow has rank 1 it will be excluded from the resulting table

Anonymous
Not applicable

Hi @stribor45 ,

 

Try it.

 

 

DEFINE
    VAR _date1=DATE(2023,1,1)  //You can change this date variable to suit your needs
    VAR _date2=DATE(2023,1,3)  ////You can change this date variable to suit your needs
    VAR REPS =
      FILTER (
        ADDCOLUMNS (
            SUMMARIZE (
                FILTER (
                    'Table_A',
                    
                   'Table_A'[Call Date] IN DATESBETWEEN('Table_A'[Call Date],_date1, _date2)
                ),
                'Table_A'[Name]
            ),
            "@count", CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
            "@rank",
                RANKX (
                    ALL ( 'Table_A'[Name] ),
                    CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
                    ,
                    DESC,
                    DENSE
                )
        ), //addcolumns
        [@rank] = 1 || [@rank] = 2 )
      
       
EVALUATE
REPS

 

 

Or:

 

 

DEFINE
    VAR _date1=DATE(2023,1,1)  //You can change this date variable to suit your needs

    VAR REPS =
      FILTER (
        ADDCOLUMNS (
            SUMMARIZE (
                FILTER (
                    'Table_A',
                   
                   'Table_A'[Call Date] =_date1
                ),
                'Table_A'[Name]
            ),
            "@count", CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
            "@rank",
                RANKX (
                    ALL ( 'Table_A'[Name] ),
                    CALCULATE ( COUNT ( 'Table_A'[ID] ) ),
                    ,
                    DESC,
                    DENSE
                )
        ), //addcolumns
        [@rank] = 1 || [@rank] = 2 )
      
       
EVALUATE
REPS

 

 

If I've misunderstood you, please accept the current post answer as a solution and create a new post detailing your new questions and expected results, thanks in advance.

 

 

Best Regards,

Neeko Tang

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

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.