Forum Discussion

Jalal_1988's avatar
Jalal_1988
Brass Contributor
Dec 06, 2023
Solved

Power Query Add new balance type when Balance = 0, by Customer'

Hello my Friends   I have problem in power query thank you for your help I want to create a column like L power query,  when the balance reach to zero change the letter and also when the costumer...
  • Lorenzo's avatar
    Lorenzo
    Dec 07, 2023

    Jalal_1988 

     

    In a nutshell:
    #1 Add an Index ([RID]) to the source table
    #2 Groub By [CUSTOMER]
    #3 For reach [CUSTOMER] add a Balance ID ([BID]) - done with https://learn.microsoft.com/en-us/powerquery-m/list-generate
    #4 Combine all Customer nested tables ([DATA]) = 'CustomerBalanceId'
    #5 Build a table with numbers from 1 to Max of all [BID] and the correspoding char. (1 = A, 2 = B, ...) = 'TableBalanceType'

    NB: If > 26 (letter Z) next will be AB, AC...

    #6 Join 'CustomerBalanceId' & 'TableBalanceType' on [BID]
    #7 Sort [RID] Ascending *

     

    * Remember that Grouping & Merging operations cannot guarantee an ordered set of records. Hence adding and Index at the beginning and sorting that Index at the end

Resources