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
vitexo87
Post Prodigy
Post Prodigy

Using conditional on consultation?

When loading data from a database to power bi prciso I use a conditional, for example, select column from table where's Columna> ColumnB

1 ACCEPTED SOLUTION

Hi vitexo87,

 

Yes, we can use Case expressions when we connect to SQL Server database. Please refer to screenshots below:

 

a1.PNG

 

a2.PNG

 

a3.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

9 REPLIES 9
v-qiuyu-msft
Community Support
Community Support

Hi vitexo87,

 

From your description, I'm not very clear about your question? Would you please elaborate the issue?

 

By the way, in power BI Desktop, to get data from a SQL Server database, we are able to write a SQL query with Where clause contained.

 

If you have any question, please feel free to ask.

 

Best reagrds,
Qiuyun Yu

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

after making the load of the data I need to edit the query that burden for future charges and enter the option of editing queries from power two and click on the table in question shows the script runs this charge, it is possible to edit this script? if yes how the script would be to apply a condicionao a column is greater than the other, for example: Source = {[Item = "FTEGF_RequisicaoBloqueada" Schema = "dbo" Catalog = "TeresinaDw"]} [Date]

Hi vitexo87,

 

In Power BI Desktop, after importing data, we can also edit query in Advanced Editor. The Power query to get SQL Server database data with Where clause should look that:

 

q2.PNG

 

Reference:

Power Query Formula Language in Power BI Desktop

 

If you have any question, please feel free to ask.

 

Best regards,
Qiuyun Yu

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

It is also possible to use the "CASE" function?


For example:

 

"CASE WHEN CentroCusto_ID is null
             THEN 0
             ELSE CentroCusto_ID
        END THE CentroCusto_ID "

Hi vitexo87,

 

Yes, we can use Case expressions when we connect to SQL Server database. Please refer to screenshots below:

 

a1.PNG

 

a2.PNG

 

a3.PNG

 

Best Regards,
Qiuyun Yu

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

It's not recommended to type a custom SQL query when loading data into Power BI - this stops the query from using "query folding".  Query folding is when the query sends the instructions back to the database to do the processing at the database level as opposed to having the Power BI engine process the query instructions. Query folding is good because the database engine will usually complete these operations much quicker.  If you write a custom SQL statement then all other later operations in your query won't be able to query fold.

 

Better options - create a view in the SQL database and use that to pull in your data OR use the Power BI query editor.

 

Short answer, you can use the CASE statement but there are better approaches.

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

Hi vitexo87,

 

Yes, we can use Case expressions when we connect to SQL Server database. Please refer to screenshots below:

 

a1.PNG

 

a2.PNG

 

a3.PNG

 

Best Regards,
Qiuyun Yu

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

thank @v-qiuyu-msft

 

It was the same to my question, I'm trying to apply a condition such as "where" that would bring all the table information from the column The values are greater than the column B, for example, where Column_A> Column_B

austinsense
Impactful Individual
Impactful Individual

What exactly is the question?

 

Maybe you're asking, should you include the conditional in the SQL code or do the filtering in the Power BI query editor instead?

 

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

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.