Forum Discussion

LFM's avatar
LFM
Icon for Helper III rankHelper III
1 year ago
Solved

Summing measure

Hello. I have a measure and I want to sum all the values in that measure. F.eks. I want to sum all the values for the table visual as shown under. 

It doesnt seems to be working to sum all values for a certain measure.


I have tried the measure shown under:

Daily average trading =
VAR CurrentDate = MAX('Total value trading'[TradeDate])
RETURN
CALCULATE (
    AVERAGE ('Total value trading'[TotalValue]),
    FILTER (
        ALL ('Total value trading'),
        'Total value trading'[TradeDate] <= CurrentDate
    )
)
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi LFM ,

    You can create two measures as below to get it:

    Culmulative values = 
    CALCULATE (
        SUM ( 'Total value trading'[Value] ),
        FILTER (
            ALLSELECTED ( 'Total value trading' ),
            'Total value trading'[Date] <= SELECTEDVALUE ( 'Total value trading'[Date] )
        )
    )
    Daily average trading = 
    VAR _date =
        SELECTEDVALUE ( 'Total value trading'[Date] )
    VAR _tab =
        ADDCOLUMNS (
            ALLSELECTED ( 'Total value trading' ),
            "@count",
                COUNTX (
                    FILTER (
                        ALLSELECTED ( 'Total value trading' ),
                        'Total value trading'[Date] <= _date
                    ),
                    [Date]
                )
        )
    RETURN
        DIVIDE ( [Culmulative values], MAXX ( _tab, [@count] ) )

    If the above one can't help you figure out, please provide some sample data in the table 'Total value trading' (exclude sensitive data) with Text format and your expected result with backend logic base on the provided sample data. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

2 Replies

  • You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi LFM ,

    You can create two measures as below to get it:

    Culmulative values = 
    CALCULATE (
        SUM ( 'Total value trading'[Value] ),
        FILTER (
            ALLSELECTED ( 'Total value trading' ),
            'Total value trading'[Date] <= SELECTEDVALUE ( 'Total value trading'[Date] )
        )
    )
    Daily average trading = 
    VAR _date =
        SELECTEDVALUE ( 'Total value trading'[Date] )
    VAR _tab =
        ADDCOLUMNS (
            ALLSELECTED ( 'Total value trading' ),
            "@count",
                COUNTX (
                    FILTER (
                        ALLSELECTED ( 'Total value trading' ),
                        'Total value trading'[Date] <= _date
                    ),
                    [Date]
                )
        )
    RETURN
        DIVIDE ( [Culmulative values], MAXX ( _tab, [@count] ) )

    If the above one can't help you figure out, please provide some sample data in the table 'Total value trading' (exclude sensitive data) with Text format and your expected result with backend logic base on the provided sample data. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards