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!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live 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
| User | Count |
|---|---|
| 51 | |
| 40 | |
| 35 | |
| 23 | |
| 22 |
| User | Count |
|---|---|
| 134 | |
| 103 | |
| 57 | |
| 43 | |
| 38 |