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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.