Power BI - how to get reports on Power BI web on the basis of parameters - powerbi

I am new to Power BI, doing some work.
I have millions of records in SQL Server database, what i want to achieve is..
whenever my colleagues open the report on Power BI, it must ask for the date parameter.
Once the date is submitted, then it must go to the SQL Server and fetch the data and then it must display the report.
Is it possible?
If it is, could some one please show me how to achieve it?

If you define a parameter in your report and use it for filtering data, when you load the report, the data matching the filter will be loaded. You can provide a default value, that you know will return no data (e.g. date in the future, if you are showing the data on or after some date).
You can declare a parameter (in your case of date data type) and use it to filter the data. To declare it, open your report in Power BI Desktop, go to Power Query Editor (by clicking on Edit Queries button in the ribbon) and define a new parameter in Manage Parameters dialog:
Make sure the data type of the parameter matches the type of your data, i.e. if your data has time, define Date/Time parameter. If your data is Date, define Date data type parameter.
Then go to your query, which you want to filter and click on the button in the header of the column you which to filter. In Date/Time filters menu choose how to filter the data, e.g. to fetch the data that is on or after some date:
Then you can close Power Query Editor and return to the report. You can change the parameter's value from the drop down under Edit Queries - Edit Parameters.
If you want to avoid loading data for the default value of the parameter, you can save this report as template (File -> Export -> Power BI template), and then send this template to your colleagues. When they open it, they will be prompted to enter values for the defined parameters, and only after that, the report will connect to the data source and fetch the matching data. This means that first, you didn't use Power BI Online, but shared the report as a file, and second your colleagues has access to the data source to be able to load the data.
If you must publish the report to Power BI Online, then you can use completely different technique - instead of defining a parameter, pass the filter in the report's URL. When the report is loaded normally (e.g. you go to the workspace and open the report), it will show all the data (it will not be filtered). However, you can prepare a special URL for your colleagues, by appending ?filter=MyTable/DateColumn ge 2019-02-04 to the report's URL that you see in the browser's address bar. Replace MyTable with the name of the table you want to filter (e.g. SalesData) and DateColumn with the name of the field on which you want to filter (e.g. SalesDate). If there are spaces in these names, you must replace them with _0x0020_, but if possible, just avoid them. After that the filter defines an operator for filtering, e.g. ge means greater than or equals. And at the end is the value (the date in your case).
You can make a web page, where the user can select a date, and this page will generate the appropriate URL for your report. Or you can make another report, where the URL is constructed as a computed column or a measure based on some conditions (e.g. selecting a date from a slicer) and the user can click on the hyperlink, which will load the actual report, but filtered.

Related

Can I programatically pass a parameter value to a PowerBI report?

I have an embedded PowerBI report that needs to execute a query with a parameter that changes depending on which client opens a report. I need to programatically pass the value of a parameter (that cannot be prepopulated inside a filter) so that I can then use this value to execute the SQL query.
Also this parameter should not be visible/modifiable to the reader of the report because they would be able to change the value and see data they were not supposed to see.
I tried passing a value programatically to a filter but the filter needs to contain the value in order to set the value being passed.
You can do this with a Paginated Report using a Hidden Parameter, but not a Power BI Interactive Report. See In SSRS, how does an "Internal" parameter differ from a "hidden" parameter?

How do you create a parameter list drop down in Power BI?

I have always been able to create drop-down list parameters within SSRS that allow the user to dynamically filter their reports based on one or more values selected from the drop-down list box of multiple values.
Translating now over to Power BI I cannot find any documentation to achieve the same functionality.
I've found a method of turning the slicer into a drop down list box. But it only allows for the selection of 1 value at a time. So it essentially seems to me to be more of a drop-down list of radio buttons.
In SSRS I could create a stored procedure that accepted a value and returned a record set filtered on a specific value(s).
I can see how to do this with Power BI as well but the method I've seen demonstrated, forces the user to select a value before the report is loaded and subsequently loads a pre-rendered report template. Which isn't the same.
So how does one go about creating a report that implements a true drop-down list box allowing for selection of 1 or more values to dynamically generate the result in the report?
Reference links are welcome if a simple answer isn't possible.
This is an out-of-the-box feature in PowerBI
Create a slicer visual and, as you've already discovered, set it to Dropdown type using the upside down carrot icon on the slicer header. The dropdown list is multi-select by default. Hold down [ctrl] while making the multiple selections. However, you can control Multi-Select behavior under the 'paintbrush.' When the visual is active, click the paintbrush icon under visualizations, expand 'Selection Controls' and you will see several options to manage your slicer's behaviors.
Additionally, you may want to explore the new filter experience, which is still in beta. https://learn.microsoft.com/en-us/power-bi/power-bi-report-filter-preview
Otherwise, The behavior in SSRS where the report loads from data sources using parameters chosen by users either as parameters in stored procedures or incorporated into dynamic SQL is not replicated in PowerBI. It's true that there are parameters that can be incorporated in that way with the data set refresh - but these are controlled on the data set, not the report, and are not convenient (or appropriate, really) for report viewers to manipulate.

How to transfer the value from the filter to Power Query and insert it into the query?

I have a report that displays data for a certain period. There are two parameters in the report: the start date and the end date. Data is displayed for the specified period. I want to dynamically load data using a filter in the report, rather than changing the parameters of the query. How can this be implemented?
You can set up a Direct Query where it pulls in the data only when it needs it.
Note that you can have a composite model where some tables are Direct Query and others are Import.

Power BI change data source parameter

Is it possible and how change data source parameter value with slicer or check box click in power bi without manual edit and then refresh data.
No, it isn't possible. However, you can make a report which connects and reads all the data sources, and use a What-if parameter with slicer to calculate result based on one of the data sources only (depending on the what-if parameter's value).

Variable in a Power BI query

I have a SQL query to get the data into Power BI. For example:
select a,b,c,d from table1
where a in ('1111','2222','3333' etc.)
However, the list of variables ('1111','2222','3333' etc.) will change every day so I would like the SQL statement to be updated before refreshing the data. Is this possible?
Ideally, I would like to keep a spreadsheet with a list of a values (in this example) so before refresh, it will feed those parameters into this script.
Another problem I have is the list will have a different nr of parameters so the last variable needs to be without a comma.
Another option I was considering is to run the script without the where a in ('1111','2222','3333' etc.) and then load the spreadsheet with a list of those a's and filter the report down based on that list however this will be a lot of data to import into Power BI.
It's my first post ever, although I was sourcing help from Stackoverflow for years, so hopefully, it's all clear.
I would create a new Query to read the "a values" from your spreadsheet. I would set the Load To / Import Data option to Only Create Connection (to avoid duplicating the data).
Then in your SQL query I would remove the where clause. With that gone you actually don't need to write custom SQL at all - just select the table/view from the Navigation UI.
Then from the the "table1" query I would add a Merge Queries step, connecting to the "a values" Query on the "a" column, using the Join Type: Inner. The resulting rows will be only those with a matching "a" column value (similar to your current SQL where clause).
Power Query wont be able to send this to your SQL Server as a single query, so it will first select all the rows from table1. But it is still fairly quick and efficient.