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
Anonymous
Not applicable

TOPN with filters?

I have a query - recordId, department, date and a calculated column (number of business days minus holidays and weekends using a database function). Each department may have different recordId for the same date. 

Perhaps I'm overthinking it - I am creating a card that shows the number of businessdays for each department with the earliest date, just 1 of any recordId(s). 

 

So far,

1) Change businessdays summarization to Don't summarize. 

2) I have created 1 measure that looks for MIN date for each departments.

HRMinDt = CALCULATE(MIN('Query'[Date]), FILTER('Query','Query'[Department]="HR"))

3)  also 1 measure for TOP1ID = TOPN(1, VALUES(Query[RecordID])

 

The idea was to get businessdays value for the recordID (filtered by measure #2 - TOP1ID) and min date for department (filtered by measure #3). 

 

Before that, I have tried the following without success:

Measure1 = CALCULATE ('Query'[businessdays], 'Query'[Department] ="HR", 'TABLE'[date] = MIN( 'Query'[date]))
OR
Measure1 = CALCULATE (TOPN(1,'Query'[businessdays]), 'Query'[Department] ="HR", 'Query'[date] = MIN( 'Query'[date]))
Error: "A single value for column 'businessdays' in table 'table' cannot be determined. This can happen when a measure formula referes to a column that contains many values without specifying an aggregation such as min, max or sum to get a single result."

 

OR TOPN(1, VALUES('Query'[businessdays]), FILTER('Query', 'Query'[Department]="HR"))

Error: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

Any suggestions are appreciated. Feel free to correct me if I'm overthinking it. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Reworked the query and fixed the issue. 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Reworked the query and fixed the issue. 

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.

Top Solution Authors
Top Kudoed Authors