Skip to content

Instantly share code, notes, and snippets.

@1504168
Last active April 13, 2022 15:03
Show Gist options
  • Select an option

  • Save 1504168/146ade4a63894f04399008e2353f78c6 to your computer and use it in GitHub Desktop.

Select an option

Save 1504168/146ade4a63894f04399008e2353f78c6 to your computer and use it in GitHub Desktop.
/*Count of occurence and SumIfs From two different Column
@Author: Md.Ismail Hosen
@Email: [email protected]
@Param: NameData : This is the column which has header text
@Param: ValueData : This is the column from which we need to SumIf
*/
CountAndSumReport=LAMBDA(NameData,ValueData,
LET(
UniqueFirstData,UNIQUE(NameData),
CHOOSE({1,2,3},UniqueFirstData,COUNTIF(NameData,UniqueFirstData),SUMIF(NameData,UniqueFirstData,ValueData))
)
)
/*This will Extract Non Digit ([email protected])>>[email protected]
@Author: Md.Ismail Hosen
@Email: [email protected]
@Param: SourceText : This is the input text which contains both number and digit.
@PossibleError: #CALC! if there is only numbers.
*/
ExtractNonDigit=LAMBDA(SourceText,
LET(
Chars,MID(SourceText,SEQUENCE(LEN(SourceText),1),1),
ReplaceDigitWithComma,REDUCE("",Chars,LAMBDA(ConsolidatedText,CurrentChar,ConsolidatedText & IF( NOT(ISNUMBER(VALUE(CurrentChar))),CurrentChar,IF(RIGHT(ConsolidatedText,1)<>",",",","")))),
XML,"<root><child>" & SUBSTITUTE(ReplaceDigitWithComma,",","</child><child>") & "</child></root>",
SplittedNumbers,FILTERXML(XML,"//child"),
FILTER(SplittedNumbers,(NOT(ISERROR(SplittedNumbers)))*(NOT(ISNUMBER(SplittedNumbers))))
)
)
/*This will Extract Digit ([email protected])>>1997
@Author: Md.Ismail Hosen
@Email: [email protected]
@Param: SourceText : This is the input text which contains both number and digit.
@PossibleError: #CALC! if there is only non digits.
*/
ExtractNumbers=LAMBDA(SourceText,
LET(
Chars,MID(SourceText,SEQUENCE(LEN(SourceText),1),1),
ReplaceNonDigitWithComma,REDUCE("",Chars,LAMBDA(ConsolidatedText,CurrentChar,ConsolidatedText & IF(ISNUMBER(VALUE(CurrentChar)),CurrentChar,IF(RIGHT(ConsolidatedText,1)<>",",",","")))),
XML,"<root><child>" & SUBSTITUTE(ReplaceNonDigitWithComma,",","</child><child>") & "</child></root>",
SplittedNumbers,FILTERXML(XML,"//child"),
FILTER(SplittedNumbers,ISNUMBER(SplittedNumbers))
)
)
/*FrequencyCount From a Single Column Data
@Author: Md.Ismail Hosen
@Email: [email protected]
@Param: SourceData : This is the column for which we need to count.
*/
FrequencyCount=LAMBDA(SourceData,
LET(
UniqueFirstData,UNIQUE(SourceData),
CHOOSE({1,2},UniqueFirstData,COUNTIF(SourceData,UniqueFirstData))
)
)
/*SumIfs From two different Column
@Author: Md.Ismail Hosen
@Email: [email protected]
@Param: NameData : This is the column which has header text
@Param: ValueData : This is the column from which we need to SumIf
*/
TotalReport=LAMBDA(NameData,ValueData,
LET(
UniqueFirstData,UNIQUE(NameData),
CHOOSE({1,2},UniqueFirstData,SUMIF(NameData,UniqueFirstData,ValueData))
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment