title: Using of Distinct by in dataweave for CSV output in mulesoft
body: <p>I am using data weave connector in my mule flow ..</p>
  
  <p>Details:- From input side I am getting collection of array and I want to convert into CSV and write into the file.</p>
  
  <p>But for particular column I am getting duplicates value and I want to remove them through data weaver.But when I am putting distinct by in front of that particular column ...code is not Woking and my getting below exception.</p>
  
  <p>"Cannot coerce a :string to a :array"</p>
  
  <p>Below is the mapping I am doing from output side.</p>
  
  <pre><code>dw 1.0
  %output application/csv
  ---
  payload map ((value, index) -&gt; {
     A1: $.A1 distinctBy $ ,
     B1 $.B1,
     C1: $.C1,
     D1: $.D1,
     E1: $.E1,
   F1: $.F1
  </code></pre>
  
  <p>))</p>
  
  <p>Guys please let me know how to use distinct by for "A1 Column" or any trick to remove duplicates value for particular column inside the data weave even i have tried group by but same syntax error is coming.. :(</p>
  
  <p>Cheers, Stevin</p>