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!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi all,
Can you help me on this SQL query. I need to get only the first value or highest values by PH.pledgeid
select max(PH.pledgeid), BH.BATCHDESCRIPTION, count (BH.BATCHDESCRIPTION) as BDCount from PH
inner join BD on BD.SERIALNUMBER = PH.SERIALNUMBER and BD.SOURCECODE = PH.SOURCECODE
inner join BH on BH.ADMITNAME = BD.ADMITNAME
WHERE PH.PAYMENTTYPE ='Standing Order' and BATCHDESCRIPTION<>'Refunds Paid'
and PH.SERIALNUMBER in (Select SERIALNUMBER from C
where BLOCKPURCHASESREASON = 'Migrate')
Group By PH.pledgeid, BH.BATCHDESCRIPTION
Order by count (BH.BATCHDESCRIPTION) DESC
You can see the example below and I need only the highest for this pledge id
Many thanks
ado
Hi, @adoalan ;
You need to find the maximum value with dax, right, if so, you can try:
max =
CALCULATE ( MAX ( 'table'[count] ), ALLEXCEPT ( 'table', 'table'[pledge id] ) )
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi
I needed in SQL not in power BI
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 68 | |
| 61 | |
| 45 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 108 | |
| 107 | |
| 39 | |
| 30 | |
| 26 |