cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fábio_Developer Frequent Visitor
Frequent Visitor

POWERBI - I want to convert the condition below SQL,

Hello guys!

I want to convert the condition below SQL, to DAX. achieve success using measurement with earlier, but I get slow.

 

WHERE

tab1.cod =2
AND tab1.DATE >='20160101'
AND tab1.DATE <='20190901'
AND tab1.DATEBASE <='20170831'

AND (tab1.DATEBASE1 IS NULL OR tab1.DATEBASE1 >'20170831')

 

Thank you

 

4 REPLIES 4
Phil_Seamark Super Contributor
Super Contributor

Re: POWERBI - I want to convert the condition below SQL,

Hi @Fábio_Developer

 

Are your data time columns DATE or NUMBER?

 

Something along these lines might work

 

Table 2 = FILTER('Tab1' , AND (
                            AND (
                                AND (
                                    'Tab1'[Date] >= DATE(2016,1,1), 
                                    'Tab1'[Date] <= DATE(2019,9,1)
                                    )
                                    ,Tab1[DATEBASE] <= DATE(2017,8,31)
                                ),
                                OR(Tab1[DATEBASE1] = BLANK(),Tab1[DATEBASE1] > DATE(2017,8,31))
                                )
                           )
                          

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Fábio_Developer Frequent Visitor
Frequent Visitor

Re: POWERBI - I want to convert the condition below SQL,

thanks, @Phil_Seamark

 

my data time columns this DATE.

 

Returned no value the example, I liked your example.

I will work a little more in it, I try to return success.

 

thank you again.

Phil_Seamark Super Contributor
Super Contributor

Re: POWERBI - I want to convert the condition below SQL,

Here is a slightly different syntax

 

Table = FILTER('Tab1' , 1 = SWITCH(TRUE() ,
                                   Tab1[COD] = 2 
						&& Tab1[Date] >= DATE(2016,1,1) 
						&& Tab1[Date] <= DATE(2019,1,1)
						&& Tab1[DATEBASE] <= DATE(2017,8,31)
						&& (		Tab1[DATEBASE1] = BLANK() 
								-- OR --
								|| Tab1[DATEBASE1] > DATE(2017,8,31)
							),
						-- THEN -- 
                                    1 ,
						-- ELSE --
                                    0
                                    )
						)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

v-jiascu-msft Super Contributor
Super Contributor

Re: POWERBI - I want to convert the condition below SQL,

Hi @Fábio_Developer,

 

Could you please mark the proper answer as solution or share the solution if it's convenient for you? That will be a big help to the others.

 

Best Regards!
Dale

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 39 members 1,741 guests
Please welcome our newest community members: