locked
How to implement a "different from" logical function RRS feed

  • Question

  • Hello,

    I use Get Metadata to retrieve files name in a blob container. I also have a README.md in this same blob container.
    I would like to be able to apply filter and set variable value in function of the files present in the blob container, but without having consideration of the README.md file. How is it possible?

    As an example, here is a logic I would like to implement for setting Variable value:

    @if(and(equals(greater(activity('FilterOnOthers').output.FilteredItemsCount,0),true),not(equals(activity('FilterOnOthers').output.Value[0],'README.md'))),'YES','NO')

    But it does not work as expected.

    Thank you for your help

    Thursday, June 13, 2019 7:21 AM

Answers

  • Hi Bertrand,

    Great question! Here's an almost fool-proof way to do so :

    • Create a variable of Array type in your pipeline, say 'x'.
    • Have the get metadata activity to read the folder and it's childItems by adding Child Items in the field list of the Dataset as shown below (highlighted) :



    • After getting the list of child items as an array in the output activity of the Get Metadata activity, chain a ForEach activity as shown in the above screenshot.
    • In the ForEach activity, for Items, use expression : @activity('Get Metadata1').output.childItems
    • In the activities tab of the forEach activity, create an ifCondition activity.
    • In the ifCondition activity, specify the condition. eg- @equals(item().name, 'README.md').
    • In the Activities tab of the ifCondition, add an "Append Variable" activity for false condition.
    • In the Append Variable, append value : @item().name to the variable 'x'.
    • Now your variable 'x' has all values except 'README.md'.

    Hope I was clear in the explanation.


    Thursday, June 13, 2019 11:10 AM

All replies

  • Hi Bertrand,

    Great question! Here's an almost fool-proof way to do so :

    • Create a variable of Array type in your pipeline, say 'x'.
    • Have the get metadata activity to read the folder and it's childItems by adding Child Items in the field list of the Dataset as shown below (highlighted) :



    • After getting the list of child items as an array in the output activity of the Get Metadata activity, chain a ForEach activity as shown in the above screenshot.
    • In the ForEach activity, for Items, use expression : @activity('Get Metadata1').output.childItems
    • In the activities tab of the forEach activity, create an ifCondition activity.
    • In the ifCondition activity, specify the condition. eg- @equals(item().name, 'README.md').
    • In the Activities tab of the ifCondition, add an "Append Variable" activity for false condition.
    • In the Append Variable, append value : @item().name to the variable 'x'.
    • Now your variable 'x' has all values except 'README.md'.

    Hope I was clear in the explanation.


    Thursday, June 13, 2019 11:10 AM
  • Hi Chirag,

    Many thanks for your reply, it is very helpful ! It just matches my use case.

    Thursday, June 13, 2019 12:33 PM
  • Glad to be of help! Very good question indeed ! 
    Thursday, June 13, 2019 1:16 PM