简体   繁体   English

在我的 SQL 查询中使用 Power BI 中的时间选择器作为参数

[英]Use time selector from Power BI as an argument in my SQL query

I have a simple query like :我有一个简单的查询,如:

SELECT COUNT(DISTINCT(p.id_organization)) AS Count
FROM dbo.paiement p
WHERE p.statut = 'AUTHORIZED'
      AND p.[date] > '2018-01-30'

I try to show this data on a PBI dashboard where I have a date range selector.我尝试在有日期范围选择器的 PBI 仪表板上显示此数据。 I want the date to be fill with the begin and end date in two different areas so the calculation refresh on the fly.我希望日期在两个不同的区域填充开始和结束日期,以便计算即时刷新。 How can I link the AND p.[date] > 'XXXX-XX-XX' to this selector ?如何将AND p.[date] > 'XXXX-XX-XX'到这个选择器?

EDIT编辑

I just find out that I can do something like我只是发现我可以做类似的事情

Associations Actives = 
CALCULATE(
    DISTINCTCOUNT('BDD - Paiement'[id_organization]),
    FILTER(
        ALLSELECTED('Dates'[Date]),
        ISONORAFTER('Dates'[Date], MAX('Dates'[Date]), DESC)
    )
)

But I want to have a BETWEEN BeginDate AND EndDate corresponding the time slider但我想要一个BETWEEN BeginDate AND EndDate对应于时间滑块

PS : How do you call this kind of query bellow ? PS:你如何称呼这种查询波纹管?

There are two approaches to this.对此有两种方法。

  1. Import all the data you might need and do the filtering within Power BI.导入您可能需要的所有数据并在 Power BI 中进行筛选。

  2. If there's too much data to import, you can create a DirectQuery.如果要导入的数据过多,您可以创建 DirectQuery。 This will pass your slicer selections back to the server on the fly and automatically pull the bits it needs.这会将您的切片器选择即时传递回服务器并自动提取所需的位。

What you can't do is pass slicer selections to your Query Editor connection string.您不能做的是将切片器选择传递给您的查询编辑器连接字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM