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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
How do i write sub query in dax?
Query :
select YEAR([CloseDate]),MONTH([CloseDate]), sum(days_to_close)/count(distinct id) as 'Number of Days to Close' from
(select [CloseDate], id, days_to_close from [dbo].[test]
where sname='Closed' group by [CloseDate], id, days_to_close) a
group by YEAR([CloseDate]),MONTH([CloseDate])
order by 1,2
Solved! Go to Solution.
Hi @Anonymous ,
Sample data:
You need to add year ,month on base table:
Then use the below dax to create a new table:
TEST2 = SUMMARIZE(FILTER(test,test[sname]="Closed"),test[YEAR],test[MONTH],"Number of Days to Close",DIVIDE(SUM(test[days_to_close]),DISTINCTCOUNT(test[id])))
Output result:
And in sql:
Did I answer your question? Mark my post as a solution!
Best Regards
Lucien
Hi @Anonymous ,
Sample data:
You need to add year ,month on base table:
Then use the below dax to create a new table:
TEST2 = SUMMARIZE(FILTER(test,test[sname]="Closed"),test[YEAR],test[MONTH],"Number of Days to Close",DIVIDE(SUM(test[days_to_close]),DISTINCTCOUNT(test[id])))
Output result:
And in sql:
Did I answer your question? Mark my post as a solution!
Best Regards
Lucien
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 103 | |
| 80 | |
| 63 | |
| 50 | |
| 45 |