Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello,
I'm very new to PowerBI Desktop. How do I select 150 records with two conditions? If it's in SQL, it would be like this below:
SELECT TOP(150)*
FROM dbo.CUSTOMER
WHERE BATCHREF = "DRM" AND SAMPLE = "No"
I play around with TOPN but I don't know how to add conditions. Please help.
Thank you
Solved! Go to Solution.
Hi @siumui ,
You can create a calculated table like this:
Table =
TOPN (
5,
FILTER (
ALL ( CUSTOMER ),
'CUSTOMER'[BARCHREF] = "DRM"
&& 'CUSTOMER'[SAMPLE] = "No"
),
'CUSTOMER'[ID], ASC
)
Attached a sample file in the below, hopes it could help.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @siumui ,
You can create a calculated table like this:
Table =
TOPN (
5,
FILTER (
ALL ( CUSTOMER ),
'CUSTOMER'[BARCHREF] = "DRM"
&& 'CUSTOMER'[SAMPLE] = "No"
),
'CUSTOMER'[ID], ASC
)
Attached a sample file in the below, hopes it could help.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-yingjl
I tried the codes. It works awesome!!! Thank you for all your help!! 🙏
@siumui ,first create a measure
measure=calculate(countrows(filter(CUSTOMER,CUSTOMER[BATCHREF] = "DRM" && CUSTOMER[SAMPLE] = "No")))
then try TOPN
Top 10 Rank = CALCULATE([measure],TOPN(10,all(CUSTOMER[CUSTOMER Id]),[measure],DESC),VALUES(CUSTOMER[CUSTOMER Id]))
Hi @amitchandak
I follow your instructions and create a measure in report Modeling by choose "New measure". Then I go to the Data, click on Table Tools and select "New table" then I entered the code you have written for TOPN in the formula bar. It gives me the error "The expresion specified in the query is not valid table expression." It doesn't tell me where/what. Please help.
Thank you.
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 58 | |
| 52 | |
| 40 | |
| 17 | |
| 16 |
| User | Count |
|---|---|
| 111 | |
| 109 | |
| 40 | |
| 33 | |
| 26 |