<?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 Do Reduction on 2 Different Fields in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-Do-Reduction-on-2-Different-Fields/m-p/1526629#M37849</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been browsing the website and I have not been able to understand how to do two different reductions for different fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 different datasets that must have reductions on their respective fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to Alias the second reduction. The Alias brings back no errors but I don't get the specified security that I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my Section Access:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SECTION ACCESS;
SELECT
CASE WHEN Active = 0 THEN 'dummy' ELSE Access END AS [ACCESS],
CASE WHEN Active = 0 THEN 'dummy' ELSE UserId END as [USERID],
REDUCTION,
REDUCTION AS REDUCTION1
FROM BrokerFlow_NEW..QlikAccess;
SECTION APPLICATION;



I Pull one of my reductions like so:&amp;nbsp;

[AGENTBROKER]:
LOAD Autonumber(Agent &amp;amp;'_' &amp;amp; AGENTID) as %keyAgentID, Autonumber(Agent &amp;amp;'_' &amp;amp; AGENTID &amp;amp;'_' &amp;amp; Broker &amp;amp; '_' &amp;amp; Coverage) as %keyAgentBrokerCoverageID, *;
SELECT 
B.Agent, 
B.AGENTID, 
B.Broker, 
B.Broker as REDUCTION,
B.Coverage, 
B.SubmitDate, 
Case 
WHEN B.SubmitDate &amp;gt; DATEADD(D, -180, GETDATE()) THEN 0
WHEN B.SubmitDate BETWEEN DATEADD(D, -365, GETDATE()) AND DATEADD(D, -181, GETDATE()) THEN 1
WHEN B.SubmitDate BETWEEN DATEADD(D, -730, GETDATE()) AND DATEADD(D, -366, GETDATE()) then 2
else 3
end as SubmitBucket
FROM (
SELECT A.Agent, A.AGENTID, A.Broker, A.Coverage, A.SubmitDate, ROW_NUMBER() Over (Partition By A.AGENTID, A.Coverage ORDER BY A.SubmitDate DESC ) as Row
FROM (
SELECT 
P.Name as Agent,
P.ProducerID as AGENTID,
U.Name as Broker,
C.Description as Coverage,
MAX(CONVERT(DATE,Q.Received)) AS SubmitDate
FROM
CIS..Quote Q 
LEFT JOIN CIS..UserID U ON Q.AcctExec = U.UserID
LEFT JOIN CIS..Producer P ON Q.ProducerID = P.ProducerID
LEFT JOIN CIS..Coverage C ON Q.CoverageID = C.CoverageID
WHERE Q.DivisionID IN ('1','2','6','3')
GROUP BY P.Name,P.ProducerID, U.Name, C.Description
HAVING P.Name IS NOT NULL AND U.Name IS NOT NULL AND P.ProducerID &amp;lt;&amp;gt; 'AGT002') A ) B WHERE B.Row = 1;&lt;/PRE&gt;&lt;P&gt;Here is the second reduction:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;LEFT JOIN 
(
SELECT 
A.Id as StrataAccount_ID,
A.name as AccountName,
A.AccountCode,
A.AIM_ID as AccountAimID,
ISNULL(SB.Name, 'No Broker Assigned') as StrataBroker,
ISNULL(SB.Name, 'No Broker Assigned') as REDUCTION1
FROM tbl_Accounts A
LEFT JOIN tbl_Inter_Broker_Account IB ON A.Id = IB.Account_ID AND IB.Active = 1
LEFT JOIN tbl_Broker SB ON IB.Broker_ID = SB.BrokerID
WHERE EXISTS (SELECT 1 FROM tbl_Inter_Account_Program_Locations I WHERE I.Account_ID = A.Id AND I.Policy_ID &amp;gt; 20)
) AS StrataAccount ON StrataLocation.LocationAccountID = StrataAccount_ID&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both B.Broker and SB.Name are virtually the same field but from different tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I go about this so I can have security where whatever USERID is logging into QlikSense they can only see the information associated with their User ID?&lt;/P&gt;&lt;P&gt;The Security is not working .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks if you can help me with this&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 21:39:21 GMT</pubDate>
    <dc:creator>trstevens</dc:creator>
    <dc:date>2024-11-16T21:39:21Z</dc:date>
    <item>
      <title>How to Do Reduction on 2 Different Fields</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-Do-Reduction-on-2-Different-Fields/m-p/1526629#M37849</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been browsing the website and I have not been able to understand how to do two different reductions for different fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 different datasets that must have reductions on their respective fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to Alias the second reduction. The Alias brings back no errors but I don't get the specified security that I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my Section Access:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SECTION ACCESS;
SELECT
CASE WHEN Active = 0 THEN 'dummy' ELSE Access END AS [ACCESS],
CASE WHEN Active = 0 THEN 'dummy' ELSE UserId END as [USERID],
REDUCTION,
REDUCTION AS REDUCTION1
FROM BrokerFlow_NEW..QlikAccess;
SECTION APPLICATION;



I Pull one of my reductions like so:&amp;nbsp;

[AGENTBROKER]:
LOAD Autonumber(Agent &amp;amp;'_' &amp;amp; AGENTID) as %keyAgentID, Autonumber(Agent &amp;amp;'_' &amp;amp; AGENTID &amp;amp;'_' &amp;amp; Broker &amp;amp; '_' &amp;amp; Coverage) as %keyAgentBrokerCoverageID, *;
SELECT 
B.Agent, 
B.AGENTID, 
B.Broker, 
B.Broker as REDUCTION,
B.Coverage, 
B.SubmitDate, 
Case 
WHEN B.SubmitDate &amp;gt; DATEADD(D, -180, GETDATE()) THEN 0
WHEN B.SubmitDate BETWEEN DATEADD(D, -365, GETDATE()) AND DATEADD(D, -181, GETDATE()) THEN 1
WHEN B.SubmitDate BETWEEN DATEADD(D, -730, GETDATE()) AND DATEADD(D, -366, GETDATE()) then 2
else 3
end as SubmitBucket
FROM (
SELECT A.Agent, A.AGENTID, A.Broker, A.Coverage, A.SubmitDate, ROW_NUMBER() Over (Partition By A.AGENTID, A.Coverage ORDER BY A.SubmitDate DESC ) as Row
FROM (
SELECT 
P.Name as Agent,
P.ProducerID as AGENTID,
U.Name as Broker,
C.Description as Coverage,
MAX(CONVERT(DATE,Q.Received)) AS SubmitDate
FROM
CIS..Quote Q 
LEFT JOIN CIS..UserID U ON Q.AcctExec = U.UserID
LEFT JOIN CIS..Producer P ON Q.ProducerID = P.ProducerID
LEFT JOIN CIS..Coverage C ON Q.CoverageID = C.CoverageID
WHERE Q.DivisionID IN ('1','2','6','3')
GROUP BY P.Name,P.ProducerID, U.Name, C.Description
HAVING P.Name IS NOT NULL AND U.Name IS NOT NULL AND P.ProducerID &amp;lt;&amp;gt; 'AGT002') A ) B WHERE B.Row = 1;&lt;/PRE&gt;&lt;P&gt;Here is the second reduction:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;LEFT JOIN 
(
SELECT 
A.Id as StrataAccount_ID,
A.name as AccountName,
A.AccountCode,
A.AIM_ID as AccountAimID,
ISNULL(SB.Name, 'No Broker Assigned') as StrataBroker,
ISNULL(SB.Name, 'No Broker Assigned') as REDUCTION1
FROM tbl_Accounts A
LEFT JOIN tbl_Inter_Broker_Account IB ON A.Id = IB.Account_ID AND IB.Active = 1
LEFT JOIN tbl_Broker SB ON IB.Broker_ID = SB.BrokerID
WHERE EXISTS (SELECT 1 FROM tbl_Inter_Account_Program_Locations I WHERE I.Account_ID = A.Id AND I.Policy_ID &amp;gt; 20)
) AS StrataAccount ON StrataLocation.LocationAccountID = StrataAccount_ID&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both B.Broker and SB.Name are virtually the same field but from different tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I go about this so I can have security where whatever USERID is logging into QlikSense they can only see the information associated with their User ID?&lt;/P&gt;&lt;P&gt;The Security is not working .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks if you can help me with this&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 21:39:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-Do-Reduction-on-2-Different-Fields/m-p/1526629#M37849</guid>
      <dc:creator>trstevens</dc:creator>
      <dc:date>2024-11-16T21:39:21Z</dc:date>
    </item>
  </channel>
</rss>

