Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Summing a measure

Hi,

 

I have a dataset on a list of assets which will need to be replaced as time goes on. Each has a different lifecycle so they will expire at different times. The table below is a sample and contains the asset, when it will expire and how much it will cost.

 

Assets_Medical

Main_asset_numberAssetReplacementYearAssetValueInflationCustom
1173642000$187,6357/01/2000
1173642018$267,9897/01/2018
1173642036$382,7547/01/2036
2424662005$2,095,1407/01/2005
2424662019$2,764,4927/01/2019
2424662033$3,647,6897/01/2033
2424662047$4,813,048

7/01/2047

 

 

I am trying to calculate the total value of all of the assets over time.

 

When pivoted against the Fiscal Year only the years which the asset is to be placed are dispayed (as shown in red).

 

However, I need to see the value of the asset every year, not just when the asset is replaced. I have created a measure which shows this (as shown in blue).

 

The issues I have is the total. I need it to be the sum of all of the assets, not the most recent change as is currently displayed. For instance 2006/2007 should be $187,635 + $2,095,140. How would I change my measure to show this?

 

 

Measure = 
VAR SelectedDate = LASTNONBLANK(DimDate[Date],1)

VAR LastDateOfChange = CALCULATE(
    MAX(DimDate[Date]),
    FILTER(
        ALL(DimDate), 
        DimDate[Date] <= SelectedDate &&
        [Changes] = 1
))

VAR AIV = 
CALCULATE(
    SUM(Assets_Medical[AssetValueInflation]), 
    DimDate[Date] = LastDateOfChange,
    ALLSELECTED(DimDate)
)

RETURN AIV

 

Changes = 
IF(ISBLANK(LASTNONBLANK(Assets_Medical[AssetValueInflation],1)), 0,1)

Thanks for your help!

7 Replies

  • Hi Anonymous

     

    you need to create an iteration with SUMX over the main_asset_number, i can-t provide the exact measure as i dont have access to your data to test it.

     

    but something which would make your measure (and your life) much easier, would be to modify your model to something like the below, and your measure would become a simple sum

     

    for the first asset number:

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks LivioLanzo! I agree regarding the change in the model however unfortuantely we have far too many assets for this approach to be feasible.

       

      I have tried to iterate over the SUMX as follows however am still getting some funky results

      AllItems = 
      SUMX(
      VALUES(Assets_Medical[Main_asset_number]), [Measure])

      I have uploaded a sample dataset and if you are able/willing to help further that would be greatly appreciated.

       

      Many Thanks

      Ben

      • v-cherch-msft's avatar
        v-cherch-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi Anonymous

         

        You may check below measure:

        Measure 2 = 
        VAR myTable =
            CALCULATETABLE (
                ALL ( Assets_Medical[Main_asset_number] ),
                ALLEXCEPT ( DimDate, DimDate[FiscalYearText] )
            )
        RETURN
            IF (
                HASONEFILTER ( Assets_Medical[Main_asset_number] ),
                [Measure],
                SUMX ( myTable, [Measure] )
            )
        

        Regards,

        Cherie

  • v-cherch-msft's avatar
    v-cherch-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Anonymous

     

    You may have a look at this post.It's better that if you could share your sample data which could reproduce your scenario and your desired output.You can also upload the pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.

     

    Regards,

    Cherie

    • Anonymous's avatar
      Anonymous
      Not applicable

      thanks v-cherch-msft! I have had a look at the post and tried to implement however I am still having trouble. I have uploaded a sample dataset here with the measures I currently have. 

       

      Thanks again for your help!

       

       

       

      • LivioLanzo's avatar
        LivioLanzo
        Icon for Solution Sage rankSolution Sage

        Hi Anonymous

         

        even though you've many assets you should be getting a great compression on the dataset. besides when the DAX gets simpler it also gets faster for your users to do clicky clicky draggy droppy at a reasonable speed. It is something you can test if your report's slow