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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Using Inputs From Power BI To Tell the Database to Calculate New Values?

Good morning Power BI community,

 

The following is a problem I am having with Power BI:

 

I have a Power BI report connected to a SQL database housed at Snowflake. On the report page, users can filter our database using various inputs to find a selection of Symbol-Date pairs (the primary key for this table), along with a few related values for each Symbol-Date (i.e., for each Symbol-Date there is exactly one value from columns A, B, C, D).

 

What I would like to be able to do is have the user of this report type in a value in an input field, and have the database find, for each Symbol in the output table, the first date following the current date on which the value A for that Symbol is greater than the user's input.

  • So for example, if the user's inputs lead to Power BI having a result table with the two results "ABC on 1/1/2000" and "XYZ on 1/1/2004", then I would want Power BI to be able to spit out the next date after 1/1/2000 on which ABC has a column "A" value greater than the input value (e.g. "60").

I have heard from various sources, however, that Power BI is not a great platform for performing heavy calculations, and that it would be much better if I could somehow have Power BI tell the underlying Snowflake SQL database to perform all the calculations and then have Power BI read the new results. The problem is, I have no idea how to do that. I suspect could write the SQL query which would produce the date answer from the bolded area (it would look something like "Select Min(Date) from sql_table where symbol = 'ABC' and date >= '2000-01-01' and column_A >= 60"), but I am at a loss as to how to get Power BI to tell Snowflake what the Symbol, Date, column_A values would be to actually complete the query.

 

Does anyone have any suggestions to help get me on the right track?

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi THarpin1, 

It seems that you wan to pre-filter data befor calculation, right? If so, I think you could use M code to filter data or you could wirte SQL query when it load in model by parameter. You could refer to Pass parameter to SQL Queries statement using Power BI  for details.

Best Regards,
Zoe Zhi

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

1 REPLY 1
dax
Community Support
Community Support

Hi THarpin1, 

It seems that you wan to pre-filter data befor calculation, right? If so, I think you could use M code to filter data or you could wirte SQL query when it load in model by parameter. You could refer to Pass parameter to SQL Queries statement using Power BI  for details.

Best Regards,
Zoe Zhi

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.