How to use parameterized snowflake UDF in Power BI - powerbi

I have a user defined function in snowflake with arguments and returns a table.
function orders_for_product(varchar,varchar,datetime,datetime)
I want to use this function in Power BI.
What I tried before is:
Creating a view in snowflake. But passing parameters was not possible in view.
As the dataset has many aggregations and date filters on different date columns present in different CTE's, applying filters on PowerBI desktop is giving unexpected output.
The major challenge is that the dataset has to be used in PowerBI Report Builder with parameters values entered by users.

Related

Can slicers be used a stored procedure parameter in power bi to filter underlying data

Can we pass the slicer values as stored procedure paramter when connecting to a sql for developing a PowerBI report so that once its deployed in powerbi service the end user can use slicer to filter the report
I tried to use a stored procedure which uses a date paramter ,but using slicer i am unable pass as a paramter to stored procedure
No. You cannot directly use stored procedures in DirectQuery models. If you use native sql in DirectQuery, it must be "composable", ie Power BI will run
select * from (<your query here>) b
where someslicer=somevalue...
So you can use multi-statement table-valued functions, and you can manipulate the native query using Dynamic M Parameters, and there's a workaround where you use OPENQUERY against a loopback linked server to run a stored procedure. How to use SQL Server stored procedures in Microsoft PowerBI?

Filter multiple columns using single slicer in power bi

I am new in power bi. I am creating a basic tabular report in power bi. But the catch is I have multiple dates columns in the dataset (For Eg. productvalidfrom,productvalidto,ordervalidfrom,ordervalidto). And I want to filter these columns with a single date selection.
If I select 2021-09-01 then condition for filter will be
2021-09-01>=productvalidfrom and 2021-09-01<productvalidto and 2021-09-01>=ordervalidfrom and 2021-09-01<ordervalidto
and need to all the columns from the dataset. No summarization.
Thanks in advance.
I have been able to implement this before. You will need to add a data table to your data sources. Then you will want to create relationships between the dates in your data and the date table. Only one of them will be active relationships, the rest will be inactive. Then, your slicer will use the date from your newly created date table.
This link should be able to guide you through the build.

Is it possible to change OData query, via user input, in Power BI?

I need to create something, which is being used a few times a year.
I need to get the latest rows since the report was used last.
My OData endpoint allows me to modify a timespan, to limit the number of rows I get (if I get all of them, I will get 12+ million rows).
The users aren't going to be knowing anything about Power BI, and I want to avoid them having the change the query manually. What I basically want is a slicer, allowing them to input a date, which will then be parsed into the query, instead of the original value, and then update the table with the new query.
An example of a filter on the OData query, selecting all files from 2020, is this:
Files?$filter=Created%20ge%20datetime%272020-01-01T00:00:00%2b01:00%27&$select=ID,......"
If it is possible, then how would I achieve it?
Slicers can't change queries, except in DirectQuery models. And OData isn't a DirectQuery source. You can build up a dynamic query on refresh, or you can have your users refresh using PowerBI and change a Parameter.

Adding a new data source to the existing report built with a dataset

I am new to Power BI and trying to build a report for one of our business requirements. I have access to a Power BI dataset which I imported in the Power BI desktop version. I also need to import an excel file placed in SharePoint/OneDrive and merge the data in these two sources. When I am trying to do this, I am getting the below error.
Is this feature not available in Power BI?
If not, is there a way to achieve this objective?
You are connected to a Tabular SSAS cube or Power BI Service dataset, you can't add other data sources.
You can only mix data source types in the modes direct query and import. See the limitations section of the MS docs
One option would be to recreate the Tabular data model in Power BI, over the base table/views it is based on in direct query mode, then add the SharePoint list, or add it as a table in the Tabular/Power BI Service Dataset

Power BI - Merging multiple customer tables

Connection Type: Direct Query to multiple sources so limited DAX available especially in Power Query load.
Data Model Query: The Data model is not a perfect star schema but there is an attempt to separate tables into business processes and lookup tables. There are probably a few issues to discuss the current data model. I only have 1 question at this time.
My current goal is to generate a single summarised customer table to replace the current two tables that have some measure I need like the number of app customers, a number of total customers, date customer first accessed app etc.
So I cannot merge the 2 customer tables and add calculated columns and measures at the import stage as power bi does not support or allow it and sql is out as I am using direct query. My plan is to create a summarised customer table using DAX summarise function on front end visual page, that has only the app customers and then measures like the total number of customers etc. Is this best practice or is there a better way of approaching this? Understand you would ideally do in sql, or power query but in these circumstances, I think this is the best way but wanted a second view.
Is there a reason to use Direct Query over Import? If you are in Import mode, you can easily Append the two client tables together in PowerQuery.
Treb Gatte, Power BI MVP