Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics RMS (Archived)

Percentage of Total Sales by Department?

Posted on by Microsoft Employee

Hi all,

I was wondering if it would be possible to use the Top Departments report and add a column for percentage of total sales of which that department is responsible? I am using HQ 2.0.200

Thanks for any suggestions/help!

*This post is locked for comments

  • Craig Harris Profile Picture
    Craig Harris 795 on at
    RE: Percentage of Total Sales by Department?

    Hello Archelle,   No apology necessary!  A crystal report version would be great.  Thanks for the help.

    Cheers,

    Craig

  • Suggested answer
    archelle16 Profile Picture
    archelle16 1,735 on at
    RE: Percentage of Total Sales by Department?

    hello craig! sorry for the late reply

    btw, i've tried to convert this to qrp but failed due to the restrictions of rms, but then, i can make a copy of this to crystal report. Let me know if that would be ok thanks!

  • Craig Harris Profile Picture
    Craig Harris 795 on at
    RE: Percentage of Total Sales by Department?

    Any chance of getting a copy of this report?  I've been trying to get it to work but have been unsuccessful.

    Regards,

    Craig

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Percentage of Total Sales by Department?

    Not sure I can get into QRP and it actually function, but I can just run this in SSMS and export. Thanks!

    Edit: Figured it out and it works perfectly!

  • Verified answer
    archelle16 Profile Picture
    archelle16 1,735 on at
    RE: Percentage of Total Sales by Department?

    If you know how to convert this to qrp report, here is the sql for you.

    SELECT  tbl.Name department ,

           tbl.AmtSold ,

           tbl.AmtSold / SUM(tbl.AmtSold) OVER ( ) AS Percentage

    FROM    ( SELECT    dbo.Department.Name ,

                       SUM(TE.Quantity * te.Price) AmtSold

             FROM      ( SELECT    StoreID ,

                                   TransactionNumber ,

                                   CAST(time AS DATE) datesold

                         FROM      dbo.[Transaction] WITH ( NOLOCK )

                       ) t

                       LEFT JOIN ( SELECT  StoreID ,

                                           TransactionNumber ,

                                           ItemID ,

                                           Quantity ,

                                           Price

                                   FROM    dbo.TransactionEntry WITH ( NOLOCK )

                                 ) te ON te.StoreID = t.StoreID

                                         AND te.TransactionNumber = t.TransactionNumber

                       LEFT JOIN ( SELECT  ID ,

                                           DepartmentID

                                   FROM    dbo.Item WITH ( NOLOCK )

                                 ) item ON item.ID = TE.ItemID

                       LEFT JOIN dbo.Department WITH ( NOLOCK ) ON dbo.Department.ID = item.DepartmentID

                       LEFT JOIN ( SELECT  id ,

                                           storecode

                                   FROM    dbo.Store WITH ( NOLOCK )

                                 ) store ON store.ID = T.StoreID

             WHERE     t.datesold >= '2016-01-01'

             GROUP BY  dbo.Department.Name

           ) tbl

    ORDER BY tbl.AmtSold DESC

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans