Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hello! I am looking to achieve similar SQL query in PowerQuery M language/code
I know its simple in DAX using 'CALCULATE' function but all the data needs to be imported to report
I am dealing with the huge amount of 'Factless Fact Table data' and can't really efford to load everything to the report which is exceeding the PowerBI PRO size limits
Tried DirectQuery but facing performance issues (my source is Azure MSSQL DB General Purpose: Gen5, 2 vCores). Any suggestions on performance tuning is also welcome
But I really need help on PowerQuery, appreciate in advance
EXMAPLE QUERY-1
SELECT
COUNT( DISTINCT Id ) AS Assigned,
COUNT( DISTINCT Id + IIF( Response=1, '1', null )) AS Processed,
COUNT( DISTINCT Id + IIF( Response=0 AND IsDuplicate=1, '1', null )) AS Duplicate
FROM TABLE WITH (NOLOCK)
WHERE Category='xyz' AND CustomerId=123 AND Type='I' AND Status IN (1,2,3) AND [Date] BETWEEN '2021-06-01' and '2021-06-02'
EXMAPLE QUERY-2
SELECT
COUNT( DISTINCT Id ) AS Assigned,
COUNT( DISTINCT CASE WHEN Response=1 THEN Id ELSE NULL END) AS Processed,
COUNT( DISTINCT CASE WHEN Response=0 AND IsDuplicate=1 THEN Id ELSE NULL END) AS Duplicate
FROM TABLE WITH (NOLOCK)
WHERE Category='xyz' AND CustomerId=123 AND Type='I' AND Status IN (1,2,3) AND [Date] BETWEEN '2021-06-01' and '2021-06-02'
Lastly, I have tried most of the Azure performance techniques and PowerQuery community for M code but am unlucky.
@Anonymous I really don't know what you are trying to achieve and why PQ? Didn't @selimovd reply solved that you run these queries directly with fixed value? Am I missing something in your question?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous or you can explore dynamic PQ Parameters that way you don't have to live with the fixed value data.
Dynamic M query parameters in Power BI Desktop (preview) - Power BI | Microsoft Docs
Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thanks @parry2k , its a good option totally fits my situation and I am exploring it.
And I am still crazy to achieve this in PowerQuery M code for my knowledge, any help here? 🙂
@Anonymous you can also just select your table without SQL statement and try to do the transformations in PowerQuery if you like the challenge
Hey @Anonymous ,
why don't you use the SQL statement in DirectQuery mode?
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 26 | |
| 23 | |
| 19 | |
| 18 | |
| 15 |
| User | Count |
|---|---|
| 46 | |
| 46 | |
| 43 | |
| 36 | |
| 31 |