Forum Discussion

andreaturri27's avatar
5 years ago

today - 12

Hi community, 

 

it is possibile using only one parameter in power bi for resolve this SQL query 

 

declare @date as datetime

set @date='2020-08-28 00:00:00.000'


select i.Item,
ISNULL((select count(distinct(CustSupp))
from dbo.MA_SaleDocDetail
where DocumentType = 3407874 and Qty > 0 and DocumentDate between DATEADD(month, -12, @date) and getdate() and Item = i.Item
group by item),0) as NrCustomer,

ISNULL((select sum(Qty)
from dbo.MA_SaleDocDetail
where DocumentType = 3407874 and Qty > 0 and DocumentDate between DATEADD(month, -12, @date) and getdate() and Item = i.Item
group by item),0) as Qty12,

ISNULL((select sum(Qty)
from dbo.MA_SaleDocDetail
where DocumentType = 3407874 and Qty > 0 and DocumentDate between DATEADD(month, -36, @date) and getdate() and Item = i.Item
group by item),0) as Qty36
from dbo.MA_Items I
where i.Disabled = '0'
order by i.Item

 

Thank you 

2 Replies

  • v-robertq-msft's avatar
    v-robertq-msft
    Icon for Community Support rankCommunity Support

    Hi, andreaturri27 

    What do you mean by “using only one parameter in power bi for resolve this SQL query”? Because you just posted a SQL query formula here and you also defined only one parameter “date” in this SQL query.

    Here’s a document about Parameter in Power BI, you can take a look and find if it’s helpful:

    https://docs.microsoft.com/en-us/power-query/power-query-query-parameters

     

    If you still have a problem, would you like to post some sample data in table form or pbix file(without sensitive data) and your expected result(like the chart you want to get and the correct measure value based on your sample data)?

    Thanks very much!

    How to Get Your Question Answered Quickly 

     

     

    Best Regards,

    Community Support Team _Robert Qin

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.