Forum Discussion

EstanisMiret's avatar
EstanisMiret
Frequent Visitor
7 months ago
Solved

Distinctcount, Calculate, y Objetivos

Buenas, 

 

Estoy trabajando en una visualitzación de objetivos comerciales de diferentes areas de mi empresa basandome en dos parámetros; clientes y facturación.

 

Como es lógico, la suma de las facturaciones de las áreas da la facturación del conjunto. 

En cambio hay clientes que son compartidos entre diferentes áreas, con lo que 2+2 no son 4.

 

Para calcular eso he creado una métrica tipo: Qt. Clientes = "DISTINCTCOUNT"('Clientes' [NIF])

Con un filtro de botones con el nombre de las diferentes áreas ahora puedo ver los clientes por área sin que el conjunto de clientes sea una suma, si no un recuento

 

El problema viene a la hora de añadir los objetivos. 

Tengo calculados los clientes del año anterior con la función: Qt. Clientes LY = CALCULATE([Qt Clientes], SAMEPERIODLASTYEAR (Date[Date]), pero quiero que el área 1 crezca un 10% respecto los clientes del ejercicio anterior, el área 2 un 15%, y el área 3 un 25%.

 

Necesito crear una métrica "Qt. Clientes Objetivo" que pueda filtrar por área, pero no sé como puedo hacerlo para que el resultado de todas las áreas sea un recuento y no una suma.

 

Por ejemplo, lo que tengo creado actualmente:

Qt. Clientes = "DISTINCTCOUNT"('Clientes' [NIF])

Qt. Clientes Área 1 = CALCULATE([Qt. Clientes], Área [Área]="1")

Qt. Clientes Objetivo Área 1= CALCULATE(([Qt. Clientes Área 1], SAMEPERIODLASTYEAR(Data[Data]))*1.10)

Qt. Clientes Objetivo Área 2= CALCULATE(([Qt. Clientes Área 2], SAMEPERIODLASTYEAR(Data[Data]))*1.15)

Qt. Clientes Objetivo Área 3= CALCULATE(([Qt. Clientes Área 3], SAMEPERIODLASTYEAR(Data[Data]))*1.25)

Qt. Clientes Objetivo ≠ CALCULATE([Qt. Clientes Objetivo Área 1]+[Qt. Clientes Objetivo Área 2]+[Qt. Clientes Objetivo Área 3])

 

No sé como conseguir que "Qt. Clientes Objetivo Empresa" sea un promedio y permita filtrar por áreas... Tampco sé si me he explicado debidamente.

 

¿Alguien me puede dar una solución? 

 

Gracias,

 

 

  • Yes, you’ve explained the problem very well, and this is actually a classic Power BI / DAX modeling challenge. You are very close already — the issue is not DISTINCTCOUNT, it’s how targets are aggregated across areas.

     

    I’ll explain it step by step, conceptually first, then give you a clean, scalable DAX solution (no hard-coding Area 1, 2, 3).

    Why your current approach breaks
    1. Customers are not additive
    You already handled this correctly

    2. Targets should NOT be summed
    This is the key problem: 'Qt Target Customers ≠ Area1 + Area2 + Area3', because

    • Customers can appear in multiple areas
    • Targets are area-based percentages
    • Summing targets creates double counting

    Targets must be evaluated per area, then re-evaluated at company level, not summed.

     

    You need to think like this:
    For each area:

    1. Take last year’s DISTINCT customers
    2. Apply that area’s growth %
    3. Then, Recalculate the DISTINCT customers under the current filter context

    That means:

    • No separate measures per area
    • No SUM of targets
    • Use iterator logic (SUMX) with DISTINCTCOUNT inside

    Solution
    Step1 = Create an Area Target table
    Create a small dimension table manually and lets called it as 'AreaTarget'

    Area     Growth %
    1          0.10
    2          0.15
    3          0.25

    This makes the solution: Dynamic, Scalable, and Filterable

     

    Step 2 = Create Base measures
    ---DAX---
    Qt Customers = DISTINCTCOUNT ( Customers[NIF] )
    Qt Customers LY = CALCULATE ([Qt Customers],SAMEPERIODLASTYEAR('Date'[Date]))
    ---DAX---

     

    Step 3 – Target Customers measures (KEY MEASURE)
    ---DAX---
    Qt Target Customers=
    SUMX (
       VALUES ( Area[Area] ),
      VAR Growth =
              SELECTEDVALUE ( AreaTargets[Growth %], 0 )
      RETURN
              CALCULATE (
                   [Qt Customers LY] * ( 1 + Growth )
               )
    )
    ---DAX---

     

    Why this works?
    'VALUES(Area[Area])' >> iterates each area separately
    Each area:

    • Calculates its own DISTINCT customers LY
    • Applies its own growth %

    At company level:

    • Power BI re-evaluates DISTINCTCOUNT correctly
    • No double counting
    • No incorrect sums

    What happens now in visuals?

    Visual Filter                                 Result
    Area = 1                                     Target = LY × 1.10
    Area = 2                                     Target = LY × 1.15
    Area = 3                                     Target = LY × 1.25

    No area filter (Company)           Correct company target without double counting

    • Works with slicers
    • Works with totals
    • No hard-coded areas
    • No averages needed

    Why “AVERAGE” is wrong here?
    You mentioned: “I don’t know how to make company target an average”

    • It should NOT be an average
    • It should be a re-evaluated DISTINCTCOUNT under combined filter context

    DAX does this naturally when written correctly.

     

    Important DAX takeaway

    If something is not additive (DISTINCTCOUNT, ratios, targets):

    • Never SUM measures
    • Use iterators (SUMX / AVERAGEX)
    • Let filter context do the work

    =================================================================
    Did I answer your question? Mark my post as a solution! This will help others on the forum!

    Appreciate your Kudos!!

    Jaywant Thorat | MCT | Data Analytics Coach
    LinkedIn: https://www.linkedin.com/in/jaywantthorat/
    Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
    #MissionPowerBIBharat
    LIVE with Jaywant Thorat from 10 Jan 2026
    8 Days | 8 Sessions | 1 hr daily | 100% Free

4 Replies

  • Hi EstanisMiret 

    I can only reply in English, hope it is ok

     

    point 1: I suggest you to correct the measures as follows (the multiplication should be out of CALCULATE for clarity)

     

    Qt. Clientes Objetivo Área 1= CALCULATE(([Qt. Clientes Área 1], SAMEPERIODLASTYEAR(Data[Data])))*1.10

    Qt. Clientes Objetivo Área 2= CALCULATE(([Qt. Clientes Área 2], SAMEPERIODLASTYEAR(Data[Data])))*1.15

    Qt. Clientes Objetivo Área 3= CALCULATE(([Qt. Clientes Área 3], SAMEPERIODLASTYEAR(Data[Data])))*1.25

     

    point 2: to understand filtering issues, you should show us the data model (please illustrate it and show a picture of it)

     

    point 3: how about

     

    Qt. Clientes Objetivo = [Qt. Clientes Objetivo Área 1]*DIVIDE([Qt. Clientes Área 1],[Qt. Clientes])+[Qt. Clientes Objetivo Área 2]*DIVIDE([Qt. Clientes Área 2],[Qt. Clientes])+[Qt. Clientes Objetivo Área 3]*DIVIDE([Qt. Clientes Área 3],[Qt. Clientes])

     

    ?

     

    If this helped, please consider giving kudos and mark as a solution

    @me in replies or I'll lose your thread

    Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

    Consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI

    • EstanisMiret's avatar
      EstanisMiret
      Frequent Visitor
      Thank you for your comment, but I believe that "Qt Clientes Objetivo" does not return "Qt Clientes" * average %. 
      I've added a table where i considered the % of grown to achieve, and made the following:
       
      Target = CALCULATE([LY Qt clientes]*([Goal]/COUNTROWS('Area'))
      Where Goal is the % to achieve (1.10, 1.15, 1.25), and Countrows of Area returns the amount of goals, so i can calculate the average.
       
      I'm going to do some comprovations and also to try your solution to compare. 
       
      😉 
      (sorry for my english... not so good jajajaj)
       
  • Yes, you’ve explained the problem very well, and this is actually a classic Power BI / DAX modeling challenge. You are very close already — the issue is not DISTINCTCOUNT, it’s how targets are aggregated across areas.

     

    I’ll explain it step by step, conceptually first, then give you a clean, scalable DAX solution (no hard-coding Area 1, 2, 3).

    Why your current approach breaks
    1. Customers are not additive
    You already handled this correctly

    2. Targets should NOT be summed
    This is the key problem: 'Qt Target Customers ≠ Area1 + Area2 + Area3', because

    • Customers can appear in multiple areas
    • Targets are area-based percentages
    • Summing targets creates double counting

    Targets must be evaluated per area, then re-evaluated at company level, not summed.

     

    You need to think like this:
    For each area:

    1. Take last year’s DISTINCT customers
    2. Apply that area’s growth %
    3. Then, Recalculate the DISTINCT customers under the current filter context

    That means:

    • No separate measures per area
    • No SUM of targets
    • Use iterator logic (SUMX) with DISTINCTCOUNT inside

    Solution
    Step1 = Create an Area Target table
    Create a small dimension table manually and lets called it as 'AreaTarget'

    Area     Growth %
    1          0.10
    2          0.15
    3          0.25

    This makes the solution: Dynamic, Scalable, and Filterable

     

    Step 2 = Create Base measures
    ---DAX---
    Qt Customers = DISTINCTCOUNT ( Customers[NIF] )
    Qt Customers LY = CALCULATE ([Qt Customers],SAMEPERIODLASTYEAR('Date'[Date]))
    ---DAX---

     

    Step 3 – Target Customers measures (KEY MEASURE)
    ---DAX---
    Qt Target Customers=
    SUMX (
       VALUES ( Area[Area] ),
      VAR Growth =
              SELECTEDVALUE ( AreaTargets[Growth %], 0 )
      RETURN
              CALCULATE (
                   [Qt Customers LY] * ( 1 + Growth )
               )
    )
    ---DAX---

     

    Why this works?
    'VALUES(Area[Area])' >> iterates each area separately
    Each area:

    • Calculates its own DISTINCT customers LY
    • Applies its own growth %

    At company level:

    • Power BI re-evaluates DISTINCTCOUNT correctly
    • No double counting
    • No incorrect sums

    What happens now in visuals?

    Visual Filter                                 Result
    Area = 1                                     Target = LY × 1.10
    Area = 2                                     Target = LY × 1.15
    Area = 3                                     Target = LY × 1.25

    No area filter (Company)           Correct company target without double counting

    • Works with slicers
    • Works with totals
    • No hard-coded areas
    • No averages needed

    Why “AVERAGE” is wrong here?
    You mentioned: “I don’t know how to make company target an average”

    • It should NOT be an average
    • It should be a re-evaluated DISTINCTCOUNT under combined filter context

    DAX does this naturally when written correctly.

     

    Important DAX takeaway

    If something is not additive (DISTINCTCOUNT, ratios, targets):

    • Never SUM measures
    • Use iterators (SUMX / AVERAGEX)
    • Let filter context do the work

    =================================================================
    Did I answer your question? Mark my post as a solution! This will help others on the forum!

    Appreciate your Kudos!!

    Jaywant Thorat | MCT | Data Analytics Coach
    LinkedIn: https://www.linkedin.com/in/jaywantthorat/
    Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
    #MissionPowerBIBharat
    LIVE with Jaywant Thorat from 10 Jan 2026
    8 Days | 8 Sessions | 1 hr daily | 100% Free