Link to home
Start Free TrialLog in
Avatar of tanj1035
tanj1035

asked on

SSRS, How to insert a row with calculation

Hi Experts,

I want to insert a row " % Change", so it will calculate the % change for each column.
For example, in "deal start", it will calculate (3735-2632)/2632=42%.
How can I do it? Thanks.

Please see my dataset. The column" time frame " contains value MTD & PMTD. I want to use (MTD-PMTD)/PMTD

select 'MTD' as timeframe,
sum([mtd]) as dealstart,
(select sum(VDPimpressions) from MakeMyDeal_com.[dbo].[Adobe_Periods] av inner join MakeMyDeal_com..dealer d on av.dealerid=d.DealerID where period ='MTD') as impressions,
(select sum(VDPPencils) from MakeMyDeal_com.[dbo].[Adobe_Periods] av inner join MakeMyDeal_com..dealer d on av.dealerid=d.DealerID where period ='MTD') as pencils,
(select Count(*) from makemydeal_com.."User"
WHERE  userid IN (SELECT userid
                  FROM   makemydeal_com..shopper)
       AND createdate >= Dateadd(MONTH, Datediff(MONTH, 0, CONVERT(DATE, Getdate())), 0)) as users
from [MMD_Feed].[dbo].[DART] d


union 
select 'PMTD' as timeframe,
sum([lastmonth]) as dealstart,
(select sum(VDPimpressions)from MakeMyDeal_com.[dbo].[Adobe_Periods] av inner join MakeMyDeal_com..dealer d on av.dealerid=d.DealerID where period ='PMTD') as impressions,
(Select sum(VDPPencils) from MakeMyDeal_com.[dbo].[Adobe_Periods] av inner join MakeMyDeal_com..dealer d on av.dealerid=d.DealerID where period ='PMTD') as pencils,
(SELECT Count(*) AS USERS
FROM   makemydeal_com.."User"
WHERE  userid IN (SELECT userid
                  FROM   makemydeal_com..shopper)
       AND CreateDate >= Dateadd(month, Datediff(month, -1, Getdate()) - 2, 0)
       AND CreateDate <= Dateadd(month, -1, CONVERT(DATE, Getdate() - 1))) as users
from [MMD_Feed].[dbo].[DART]

Open in new window



User generated image
ASKER CERTIFIED SOLUTION
Avatar of Nico Bontenbal
Nico Bontenbal
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tanj1035
tanj1035

ASKER

Thanks for the help. It works!!