Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Calculated column Shows Repeated Values

Hello All,

 

I am working on a measure but im getting repeated values across all the months,  can you please assist on what I am missing on the dax commands? Thank you!!

 

I am using the following measure DAX

item SUBTOTAL =
var currentfrom = selectedvalue(Layout[FROM])
var currentto = selectedvalue(Layout[TO])
return

calculate(
    [Actual value],
    FILTER(
        ALL('Act'),
        'Act'[PK]>= currentfrom  &&
        'Act'[PK]<= currentto
    )
)
 

Relationships on Layout to Act on Primary Key (PK) and Act to Date2 on Date 

Act Table

 

Layout Table

 
StatementLevel 1Level 2Primary KeyCalculationTableFROMTOHighlight TypeOperatorMain Income Statement LineBlank LineDepth
Income StatementRevenueContracts186SUM 18618611TRUE 2
Income StatementRevenueMaterials (Repairs Only)187SUM 18718711TRUE 2
Income StatementRevenueShipping, Freight188SUM 18818811TRUE 2
Income StatementRevenueService Repairs189SUM 18918911TRUE 2
Income StatementRevenueDiscounts190SUM 19019011TRUE 2

 

4 Replies

  • There is a difference between a calculated column (calculated once for each row) and a measure (calculated dynamically for each filter context change).

     

    Please provide sanitized sample data that fully covers your issue.
    https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
    Please show the expected outcome based on the sample data you provided.

    https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello,

      Thank you for assisting me on this, see below

       

      Sample file link below:

      https://we.tl/t-qD5iFsibY3?utm_campaign=TRN_TDL_05&utm_source=sendgrid&utm_medium=email&trk=TRN_TDL_05

       

      Desired Outcome

      Level 29/30/202210/31/2022
      Contracts-100000-100000
      Subcontractor expense2500050000
      Gross Profit-75000-50000
         
       

      Current outcome

      Current Measures DAX
      Actual value = SUM(Act[Value])
      item SUBTOTAL =
      var currentfrom = selectedvalue(Layout[FROM])
      var currentto = selectedvalue(Layout[TO])
      return

      calculate(
          [Actual value],
          FILTER(
              ALL('Act'),
              'Act'[PK]>= currentfrom  &&
              'Act'[PK]<= currentto
          )

       

      Tables

       

      Data:

      Organization KeyStatementFSLIDETAILEDLevel 2PKCode9/30/202210/31/2022 
      1Income StatementNet RevenueContractsContracts1864000-100000-100000 
      1Income StatementCost of Goods SoldSubcontractor expenseSubcontractor expense20350052500050000 

       

      Layout Table

      StatementLevel 1Level 2Primary KeyCalculationTableFROMTO
      Income StatementRevenueContracts186SUM 186186
      Income Statement Direct Cost of RevenueSubcontractor expense203SUM 203203
      Income StatementGross ProfitGross Profit222CALCULATION186203
      • lbendlin's avatar
        lbendlin
        Super User

        Your Layout[FROM] and Layout[TO] values are numeric.  Did you mean to specify date ranges instead?

        Replace the item SUBTOTAL field with the Value field: