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
Rai_BI
Helper IV
Helper IV

Automatically redistribute the target per customer

In Power BI I have a table with customer portfolios. In this table there are the fields Customer Code, Customer Name, Wallet Code, Wallet Name.


I also have the table with the sales record and in this table there are the Date of Sale and Customer Code fields.
I also have a table with the goals for each client portfolio and in this table there are the fields Target Month, Target Value, Portfolio Code, Portfolio Name.

 

Consider the following situation:

The "AA" portfolio sold a total of 100,000, distributed among the 3 clients that are part of the portfolio. And this portfolio has a total target of 130,000

 

The "BB" portfolio sold a total of 300,000, distributed among the 5 clients that are part of the portfolio. And this portfolio has a total target of 350,000

 

The "CC" portfolio sold a total of 250,000, distributed among the 7 clients that are part of the portfolio. And this portfolio has a total target of 280,000

 

For the "AA" portfolio, I need to apply a target to the clients of this portfolio considering the percentage weight that each client represents in the total of 100,000 in the portfolio.

 

For the "BB" portfolio I need to apply a target to the clients of this portfolio considering the percentage weight that each client represents in the total of 300,000 in the portfolio.

 

For the "CC" portfolio I need to apply a target to the clients of this portfolio considering the percentage weight that each client represents in the total of 250,000 in the portfolio.

Is it possible to create a DAX measure that is capable of performing this goal calculation automatically?

1 ACCEPTED SOLUTION
AUaero
Responsive Resident
Responsive Resident

I've created a simplified model based on your description with the following measures that you should be able to modify to get the result you're looking for.

Sales Measure:

 

$ Sales = SUM(Sales[SaleAmount])

 


Portfolio Target Measure:

 

$ Portfolio Target = 
CALCULATE(
    SUM(Goals[Target]),
    FILTER(
        Customers,
        COUNTROWS(VALUES(Customers[CustomerCode])) > 0
    )
)

 

 

Customer Target Measure:

 

$ Customer Target = 
VAR _CustomerSales = Sales[$ Sales]

VAR _TotalSales = 
CALCULATE(
    Sales[$ Sales],
    ALL(Customers),
    VALUES(Portfolio[PortfolioID])
)

VAR _PercentToTotal = 
DIVIDE(_CustomerSales, _TotalSales)

VAR _PortfolioTarget = Goals[$ Portfolio Target]

VAR _CustomerTarget = 
_PercentToTotal * _PortfolioTarget

RETURN
_CustomerTarget

 


Result:

AUaero_0-1706037075565.png

 



Consider providing a dataset to work with on future requests; this will make it much easier to answer your questions.

If this solves your problem, please mark this answer as the solution.

View solution in original post

3 REPLIES 3
AUaero
Responsive Resident
Responsive Resident

@Rai_BI - I'm sorry to hear the calculation is slow.  As I stated, I created a very simplified model to test out the DAX I provided.  It is difficult to help troubleshoot slow calculations without actually seeing your data model.

AUaero
Responsive Resident
Responsive Resident

I've created a simplified model based on your description with the following measures that you should be able to modify to get the result you're looking for.

Sales Measure:

 

$ Sales = SUM(Sales[SaleAmount])

 


Portfolio Target Measure:

 

$ Portfolio Target = 
CALCULATE(
    SUM(Goals[Target]),
    FILTER(
        Customers,
        COUNTROWS(VALUES(Customers[CustomerCode])) > 0
    )
)

 

 

Customer Target Measure:

 

$ Customer Target = 
VAR _CustomerSales = Sales[$ Sales]

VAR _TotalSales = 
CALCULATE(
    Sales[$ Sales],
    ALL(Customers),
    VALUES(Portfolio[PortfolioID])
)

VAR _PercentToTotal = 
DIVIDE(_CustomerSales, _TotalSales)

VAR _PortfolioTarget = Goals[$ Portfolio Target]

VAR _CustomerTarget = 
_PercentToTotal * _PortfolioTarget

RETURN
_CustomerTarget

 


Result:

AUaero_0-1706037075565.png

 



Consider providing a dataset to work with on future requests; this will make it much easier to answer your questions.

If this solves your problem, please mark this answer as the solution.

Thank you very much!
😄I am facing a slow calculation problem. It's taking a long time to calculate. 

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.