want to Pivot this table using linq c#
            Asked
            
        
        
            Active
            
        
            Viewed 83 times
        
    -4
            
            
        - 
                    3Stackoverflow is not a code conversion tool! – Salah Akbari Jul 31 '18 at 13:43
- 
                    2So, what have you tried so far, and where exactly are you stuck? – bassfader Jul 31 '18 at 13:44
- 
                    hope so you got my table result , i just want to pivot it using linq c# – Ani Jul 31 '18 at 13:47
- 
                    could you explain what you want to achieve? please, be more specific – smn.tino Jul 31 '18 at 14:08
- 
                    So exactly what is the problem you are having with the code you have written so far? If you show that code then maybe we can help. – PaulF Jul 31 '18 at 14:09
1 Answers
0
            
            
        Since the question does not provide what to pivot by.. I did a pivot to count on a period of 50. Change it to your preference. Check this fiddle.
var result = myList
            .GroupBy(x => x.Branch)
            .Select(y => new {
                           Branch = y.Key, 
                           FirstPeriod = y.Count(z => z.Quantity > 100 && z.Quantity <= 150), 
                           SecondPeriod = y.Count(z => z.Quantity > 150 && z.Quantity <= 200), 
                           ThirdPeriod = y.Count(z => z.Quantity > 200 && z.Quantity <= 250)
                        }).ToList();
References:
 
    
    
        Yash Malla
        
- 350
- 3
- 14
- 
                    Thanks for your time ... I was looking for dynamic column and finally i got the solution... Once again thank You for your time and efforts... – Ani Aug 01 '18 at 12:34
