Transposing Row Data as Columns in Crystal Reports

孤街醉人 提交于 2019-12-20 06:19:04

问题


I have the following data returned from a stored procedure

Staff  Category   Amount
-----  -------    ------
Bob    Art        123
Bob    Sport      777
Bob    Music      342 
Jeff   Art        0
Jeff   Sport      11
Jeff   Music      27

All Categories will always be returned for all Staff even is the Amount is zero

What I want to do on my Crystal Report is output this:-

Staff   Art     Sport   Music   
-----   ---     -----   -----   
Bob     123     777     342
Jeff    0       11      27

I effectively want to Transpose the data in the Category rows as headers or columns in my report.

I do not want to use a Cross Tab as I have other things I need to add which will not fit nicely into a Cross Tab

Any thoughts on how I can do this in Crystal? I'm using version 11


回答1:


Group the report by staff and place staff, Art, Sport, Music as text fields in Group header.

now in details section place data as

Staff, formula 1 (If Category='Art' then Amount), formula 2 (If Category='Sport' then Amount), formula 3 (If Category='Music' then Amount)

If Staff has only one value then its ok else place Staff in Group footer and take sum of all values in group footer (Don't remove Formula 1,2,3 from details)




回答2:


Should be able to achive this in your sproc with a PIVOT Table. A helpfile on PIVOT tables can be found here



来源:https://stackoverflow.com/questions/18826841/transposing-row-data-as-columns-in-crystal-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!