<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use Table-Valued Functions in MS Report Builder in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-use-Table-Valued-Functions-in-MS-Report-Builder/m-p/4320219#M38862</link>
    <description>&lt;P&gt;I have a Table-Valued Function in SQL that I'm trying to pull into MS Report Builder.&amp;nbsp; It has 4 parameters (Start Date, Version ID 1, End Date, Version ID 2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Function is:&amp;nbsp;&amp;nbsp;[dbo].[RateAttributionReportNmd] (@StartTapeDate DATE, @StartVersionId INT, @EndTapeDate DATE, @EndVersionId int)&lt;/P&gt;&lt;P&gt;However, those 4 parameters aren't actual fields in the data but I want to use them as parameters in the report so that the function parameters can be used to update the data/SQL query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT * FROM [dbo].[RateAttributionReportNmd] ('2024-10-31', 3, '2024-11-30', 2)&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2024 18:07:48 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-12-09T18:07:48Z</dc:date>
    <item>
      <title>How to use Table-Valued Functions in MS Report Builder</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-use-Table-Valued-Functions-in-MS-Report-Builder/m-p/4320219#M38862</link>
      <description>&lt;P&gt;I have a Table-Valued Function in SQL that I'm trying to pull into MS Report Builder.&amp;nbsp; It has 4 parameters (Start Date, Version ID 1, End Date, Version ID 2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Function is:&amp;nbsp;&amp;nbsp;[dbo].[RateAttributionReportNmd] (@StartTapeDate DATE, @StartVersionId INT, @EndTapeDate DATE, @EndVersionId int)&lt;/P&gt;&lt;P&gt;However, those 4 parameters aren't actual fields in the data but I want to use them as parameters in the report so that the function parameters can be used to update the data/SQL query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT * FROM [dbo].[RateAttributionReportNmd] ('2024-10-31', 3, '2024-11-30', 2)&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 18:07:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-use-Table-Valued-Functions-in-MS-Report-Builder/m-p/4320219#M38862</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-09T18:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Table-Valued Functions in MS Report Builder</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-use-Table-Valued-Functions-in-MS-Report-Builder/m-p/4320738#M38866</link>
      <description>&lt;P&gt;Hi,Anonymous&lt;/LI-USER&gt; .I am glad to help you.&lt;BR /&gt;&lt;SPAN&gt;I created the test data&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;this is my test:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;-- Checking and deleting existing tables
IF OBJECT_ID('dbo.YourDataTable', 'U') IS NOT NULL
BEGIN
    DROP TABLE dbo.YourDataTable;
END

-- Checking and deleting existing table-valued functions
IF OBJECT_ID('dbo.RateAttributionReportNmd', 'IF') IS NOT NULL
BEGIN
    DROP FUNCTION dbo.RateAttributionReportNmd;
END

-- Creating a new data table
CREATE TABLE dbo.YourDataTable
(
    ID INT PRIMARY KEY,
    TapeDate DATE,
    VersionId INT,
    Value DECIMAL(10, 2)
);


INSERT INTO dbo.YourDataTable (ID, TapeDate, VersionId, Value) VALUES 
(1, '2024-10-01', 1, 100.00),
(2, '2024-10-15', 2, 110.00),
(3, '2024-10-31', 3, 120.00),
(4, '2024-11-01', 2, 130.00),
(5, '2024-11-15', 1, 140.00),
(6, '2024-11-30', 5, 150.00),
(7, '2024-12-01', 4, 160.00),
(8, '2024-12-15', 3, 170.00),
(9, '2024-12-31', 2, 180.00),
(10, '2025-01-01', 1, 190.00),
(11, '2025-01-15', 4, 200.00),
(12, '2025-01-31', 2, 210.00);

SELECT * FROM dbo.YourDataTable;

-- Creating Table Value Functions
CREATE FUNCTION dbo.RateAttributionReportNmd 
(
    @StartTapeDate DATE, 
    @StartVersionId INT, 
    @EndTapeDate DATE, 
    @EndVersionId INT
)
RETURNS TABLE
AS
RETURN
(
    SELECT *
    FROM dbo.YourDataTable
    WHERE TapeDate BETWEEN @StartTapeDate AND @EndTapeDate
      AND VersionId BETWEEN @StartVersionId AND @EndVersionId
);

-- Testing table value function calls
SELECT * FROM dbo.RateAttributionReportNmd ('2024-10-31', 3, '2024-11-30', 5);
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Use Microsoft Report Builder/Power BI Report Builder&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;After the data source is successfully connected, the parameters used in the four table value functions are created&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-size: 11.0pt;"&gt;&lt;STRONG&gt;Add a Dataset(It is actually a call to a table function in SQL Server)&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SELECT * FROM dbo.RateAttributionReportNmd (@StartTapeDate, @StartVersionId, @EndTapeDate, @EndVersionId)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Add a table to display the data&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The final presentation results are as follows:&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Parameter settings in paginated reports are very important.&lt;BR /&gt;You need to check that you have the right type of parameter, that the parameter requires a manually selected value, and that there is no default value.&lt;BR /&gt;What is the way to get the default value (by giving a default value directly or by querying from Data Set)&lt;/P&gt;
&lt;P&gt;If you need the selected value of the parameter to be queried from the Data Set, then you need to set up a separate Data Set for these parameters to get the data, and isolate it from the Data Set of the main table data to avoid cross-references (circular dependencies)&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Parameter mappings in the dataset also need to be scrutinized&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.&lt;BR /&gt;Best Regards,&lt;BR /&gt;Carson Jian,&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 02:52:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-use-Table-Valued-Functions-in-MS-Report-Builder/m-p/4320738#M38866</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-10T02:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Table-Valued Functions in MS Report Builder</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-use-Table-Valued-Functions-in-MS-Report-Builder/m-p/4324380#M38906</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp; Brilliant!&amp;nbsp; Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 17:26:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-use-Table-Valued-Functions-in-MS-Report-Builder/m-p/4324380#M38906</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-11T17:26:16Z</dc:date>
    </item>
  </channel>
</rss>

