Forum Discussion
dynamically pass the date value
hi ,
following SQL code can be possible using dax?. i want the date parametr should be dynamic:(whatever choose by user)
when the user pass the paramer reult will display on table chart visual.
declare @strdate date ='2021-08-21'
select City,sum(sales) from
(select city,sales from Year sales where enddate<=CONVERT(date,@strdate, 120)
group by city
union all
select city,sales from Year salesTab where enddatef<=CONVERT(date,@strdate, 120)
group by city)a
group by city
please help,
5 Replies
- parry2kSuper User
fab196 you can use dynamic parameters read here Dynamic M query parameters in Power BI Desktop (preview) - Power BI | Microsoft Docs
✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) 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.⚡
- fab196Helper II
can this above code possible using dax except date parameter?
please help
- fab196Helper II
parry2k, amitchandak please reply
- AnonymousNot applicable
Hi fab196
I don't quite understand your needs, can you provide some data and screenshots to reflect the results you want ?Looking forward to your reply .
Best Regards
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- fab196Helper II
hi Anonymous thanks for your reply,
ifyou from SQL bkg then you can understand below code:
select Sum (sales) sales,sum(ordered)as oredered, sum(shipped)as shipped
from
(select count(1)ordered, 0 shipped ,city,sales from Slaes_year where enddate<=CONVERT(date,@strdate, 120)
group by city
union all
select 0 as ordered,count(1) shipped,city,sales from Sales_Year where enddate<=CONVERT(date,@strdate, 120)
group by city)a
group by cityi want ot convert this code into dax to count the sales city wise
please help