Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
andreaturri27
Helper I
Helper I

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 2
v-robertq-msft
Community Support
Community 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.

lbendlin
Super User
Super User

Use DATEADD(), EDATE, or SAMEPERIODLASTYEAR.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.