Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rishirajdeb
Advocate I
Advocate I

Implementing allocation logic in Power BI

Hi All,

 

I have to create a solution in Power BI (it's even fine to combine other Power Platform components, i.e., Power Apps & Power Automate if required). The source data contains sales amounts for different categories. Transactions with category 2 indicate that the payments for those transactions are confirmed and hence POS certificates are generated. The requirement is to allocate the amounts and certificate numbers to the category 1 transactions.

 

Mock up data as visible on a Power BI table visual:

 

rishirajdeb_0-1693845217339.png

 

Here, the total confirmed payment (category 2) is 200+300 = 500, so the ask is to allocate this 500 to the transactions with category 1. So I am looking for an output table visual in Power BI (for category 1 transactions), which should look like below after allocation:

 

rishirajdeb_1-1693845245190.png

 

In case it's not clear already, let me explain the logic here. These are all the transactions with category 1. For the first transaction, the quantity is 23 and our balance to allocate is 500. So the entire transaction amount can be attributed to the first payment certificate (123). For the sencond transaction, now the balance is 477 (500 - 23), and the transaction quantity is 56. So again, this can be assigned to the POS1 certificate, and so on.

 

The challenge is, there can be multiple confirmed payments (and hence certificates), and for each one, a new column has to appear as highlighted above, along with the Certificate column which should show the certificate number assigned to a transaction (There can be an 'Allocate' button using which end users can trigger the process. Ultimately, data from this new table would be exported and fed to an external application).

 

I am not sure whether this kind of a logic can be implemented or not in the first place (for Power BI not having efficient ways to implement loops). Would appreciate any help & suggestions.

 

@parry2k @Greg_Deckler @amitchandak @Idrissshatila @lbendlin @HarishKM @foodd @Ritaf1983 @Ashish_Mathur @danextian @aj1973 @ToddChitt @eliasayyy @tamerj1 @GilbertQ @JoeBarry @Vijay_A_Verma 

4 REPLIES 4
rishirajdeb
Advocate I
Advocate I

Attaching the data for convenience.

 

Source table:

 

countrycategoryquantityPOStransaction datetransaction id
USA123 02-05-20235064
USA156 02-05-20235406
USA178 03-05-20231878
USA143 03-05-20236842
USA1200 09-05-20233181
USA1100 09-05-20236259
USA220012309-05-20239568
USA230045609-05-20234930

 

Required output:

 

countrycategoryquantityPOS1POS2Certificate
USA12323 123
USA15656 123
USA17878 123
USA14343 123
USA1200 200456
USA1100 100456

 

If required, an Index column can also be added to the source data.

 

Thanks.

 

 

amitchandak
Super User
Super User

@rishirajdeb , I doubt with current columns, I can drive the logic. Unless there are other columns to help, like date , id etc.

Also, ideally the allocation should start from the earliest transaction date.

@amitchandak  Actually there would be other columns available in the source data. Let me update the first table with date and unique id (though an unique identifier would not be available by default, I think I should be able to create one composite key if required):

 

rishirajdeb_0-1693925809717.png

 

 Please let me know if it works, thanks for the help!!

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.