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
BrianNeedsHelp
Resolver I
Resolver I

TOPN by Date

I'm trying to caluclate the top 7 Gross Adds by month. So I use the filter topn in the filter section which works fine.   But I want to have another table next to it that adds 364 days to each top 7 dates, so as to project the future year top dates but on the same weekday.  I have a slicer that is Month Year. 

So I try a measure that results in error that "expression refers to multiple columns".  

TopFutureDates = 
        TOPN ( 
            7, 
            ALLSELECTED( 'Subscriber Activity'), 
         [Gross Adds],
            DESC 
        ) 

 So I tried:  

TopFutureDates = CALCULATE ( 
    SUMX(VALUES('Calendar'[Calendar Date]),[Gross Adds]),  
    KEEPFILTERS ( 
        TOPN ( 
            7, 
            ALLSELECTED( 'Subscriber Activity'), 
         [Gross Adds],
            DESC 
        ) 
    ) 
)

This results in a sum total of the whole month not top 7.  If I include the date in the Columns pane it shows all of the dates for the whole month.  I'm wanting it to return the top 7 values along with the date.  Then add 364 days to each date it finds.  Thanks!  

5 REPLIES 5
BrianNeedsHelp
Resolver I
Resolver I

I finally got the first part to work!  

 

TopDates = 
        CONCATENATEX(TOPN ( 
            7,
            VALUES( 'Calendar'[Calendar Date]), 
         [Gross Adds],
            DESC 
        ), [Calendar Date],CONCATENATE ( "", UNICHAR ( 10 ) ))

 

Now for future dates I got it to work with: 

 

TopFutureDates = 
        CONCATENATEX(TOPN ( 
            7,
            VALUES( 'Calendar'[Calendar Date]), 
         [Gross Adds],
            DESC 
        ), [Calendar Date]+364,CONCATENATE ( "", UNICHAR ( 10 ) ))

 

 But is there a way to display the Dates and the Gross Adds in the [TopDates] measure above?  Right now I've only been able to display either or in the [TopDates] measure.  

Measures must return a single scalar value. You can keep using CONCATENATEX but then you need to unpack that text result again yourself.  In this case Line Feed is not a useful string separator.

lbendlin
Super User
Super User

Assuming your data model is wired with Calendar as dimension and Subscriber Activity as fact

 

TopFutureDates = 
        TOPN ( 
            7, 
            ALLSELECTED( 'Calendar'[Calendar Date]), 
         [Gross Adds],
            DESC 
        ) 

Or encase it with SELECTCOLUMNS

@lbendlin I get error: Table of multiple values was supplied where a single value was expected when using: 

 

TopFutureDates = 
        TOPN ( 
            7, 
            ALLSELECTED( 'Calendar'[Calendar Date]), 
         [Gross Adds],
            DESC 
        ) 

Tried this:   

TopFutureDates = 
       SELECTCOLUMNS( TOPN ( 
            7, 
            ALLSELECTED( 'Calendar'[Calendar Date]), 
         [Gross Adds],
            DESC 
        ) )

"Too few arguments were passed to the SelectColumns function.  The minimum argument count for the function is 2."

 

Once you  have your top 7 rows, what do you want to do with them next?

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.