samedi 29 février 2020

Power BI: columns concatenation with incremented number between the columns, based on specific conditions

I am using Power BI.

I amconcatenating two columns from the same file. This is ok.

But between this concatenation, I need to add a number.

The number is determine in function of data in another file.

In another file, I have a list of values, string followed by number. The string indicate a category and the number an amount within this category.

When the string matches to a specific string in the first file, the highest number sould be selected, and then incremented, and places in the middle of my two concatenated columns.

I am struggling to do that.

I kmow that I shoulf be using part of "Text.Contains", but my issue if that the text needs to be provided. It is always the same text which needs to be searched. I also wonder how to have a Text.Contains embeded within a Text.Combine.

Text.Contains(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical 

Another issue is that I need to increment, and thus I need to have a number, but in Power BI things need to be either text or numbers.

I also found this formula on another auestion, which seems to somewhat approach what I am looking for because an incrementation is done.

Column = var currentIndex = [Index] 
         var lastFalseIndex = CALCULATE(max(Table1[Index]), 
                                        Table1[Event] = FALSE(), 
                                        Table1[Index] <= currentIndex) 
         var minIndexEachKey = CALCULATE(min(Table1[Index]),
                                         all('Table1'[Event], Table1[Index])) 
         return 
             if(ISBLANK(lastFalseIndex),
                 currentIndex - minIndexEachKey + 1 , 
                 currentIndex - lastFalseIndex)

Below are the two input files, followed by the result:

Input file with the columns that I concatenate

Second inuput file, in which I need to search for a specific category, look for the highet number and increment it

End result

Aucun commentaire:

Enregistrer un commentaire