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
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
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.