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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

TOPN with previous month

Hello people, 

 

I try to show a table with just 50 lines, and i try to create a measure to show just the TOP50 values from the last month 

 

JOliveira_1-1601296196532.png

 

 

>> and I get the error "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."

 

P.S: I can't create calculated column because i'm connected with DirectQuery

 

Help me pls

 

J.O.

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Anonymous,

 

Modify your measure as below:

 

Last_Month_price=
VAR _value=CALCULATE(MAX(fact_snapshot[last_amt]),PREVIOUSMONTH('Calendar'[Date]))
VAR _table=TOPN(50,fact_snapshot,_value,ASC)
Return
MAXX(_table,_value)

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @Anonymous,

 

Modify your measure as below:

 

Last_Month_price=
VAR _value=CALCULATE(MAX(fact_snapshot[last_amt]),PREVIOUSMONTH('Calendar'[Date]))
VAR _table=TOPN(50,fact_snapshot,_value,ASC)
Return
MAXX(_table,_value)

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

amitchandak
Super User
Super User

@Anonymous , Try like

 

all(Fact_snapshot)

or

allselected(Fact_snapshot)

Anonymous
Not applicable

Hi @amitchandak ,

 

Thanks for the reply, but I had already tried this, but the error remains the same as I described above.

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Anonymous
Not applicable

Hi @amitchandak , 

 

Sorry but it not possible.

 

But the measure "CALCULATE(MAX(fact_snapshot[last_amt]),PREVIOUSMONTH('Calendar'[Date]))" already return more than 1000000 rows. I just wont to show the TOP50 of this measure.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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