简体   繁体   English

以矩阵SSRS排序

[英]Sorting in a matrix SSRS

I try to sort the machine number ascending. 我尝试将机器编号升序排序。 If I took out the Prduct description then the machines are sorted ascending. 如果我取出产品描述,则机器按升序排序。 I would like to show the Product description for every machine and I would like to show the machines sorted(M101,M102,M103...) 我想显示每台机器的产品描述,并想显示已排序的机器(M101,M102,M103 ...)

在此处输入图片说明

where Date BETWEEN @StartDateTime AND @EndDateTime
    and Name in ('M101','M102','M103','M104','M105','M106','M107','M108','M109','M110', 'M111') 
    group by Date, Name, ProductName

    ) as s

order by Name asc

It should look like this here: 在这里看起来应该像这样:

在此处输入图片说明

在此处输入图片说明 I did used a matrix 我确实使用了矩阵

[![enter image description here][4]][4] [![在此处输入图片描述] [4]] [4]

I have try these 2 solution 我尝试了这两种解决方案

first use case when in ORDER BY clause like this 在像这样的ORDER BY子句中的第一个用例

ORDER BY CASE 
        WHEN name = 'M101' THEN 1 
        WHEN name = 'M102' THEN 2
    END 

It's not best solution but it's can solved your problem and second solution is use substring in order by clause like this 这不是最好的解决方案,但可以解决您的问题,第二个解决方案是像这样按子句使用子字符串

ORDER BY CAST(SUBSTRING(name,2,10) AS INT)

And if you use Column group for dynamic expand column don't forget delete delete sorting condition. 而且,如果您将“列”组用于动态扩展列,请不要忘记删除,删除,排序条件。 Hope it's help 希望对你有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM