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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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 CountFROM dbo.paiement pWHERE 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. 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 ?

1 ACCEPTED SOLUTION

hi, @Anonymous

The formula you had done is a measure,

and you could just drag Dates'[Date] field into a slicer and set its type is "between"

https://docs.microsoft.com/en-us/power-bi/desktop-measures

https://docs.microsoft.com/en-us/power-bi/desktop-calculated-columns

https://docs.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-slicers

 

Note: Be sure that BDD - Paiement table has created a relationship with date table.

 

Best Regards,
Lin

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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

 

PS : How do you call this kind of query bellow ?

hi, @Anonymous

The formula you had done is a measure,

and you could just drag Dates'[Date] field into a slicer and set its type is "between"

https://docs.microsoft.com/en-us/power-bi/desktop-measures

https://docs.microsoft.com/en-us/power-bi/desktop-calculated-columns

https://docs.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-slicers

 

Note: Be sure that BDD - Paiement table has created a relationship with date table.

 

Best Regards,
Lin

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.