Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
11 months ago
Solved

Cumulative Sum without repeat value

Hello PowerBi communauty, 

I did a measure DAX to cumulative sum, but when I created a plot scatter it looks like I have all "price" again at the end of the visual. I have double plots..Can you help me? How can I show my dot (price) based on cumulative Axis-X without repeat value at the end ? 

 

CALCULATE (
[Volume],
FILTER (
    ALLSELECTED ('Sheet'),
         'Sheet'[price]
            >= MAX ('Sheet'[price])
))

8 Replies

  • Please turn the visual into a table and look at the values calculated through your measure, are they ok or not?

     

    We shall go back to this visual once we are sure numbers are correct

     

    Best

     

    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

  • Shahid12523's avatar
    Shahid12523
    Community Champion

    Your scatter plot shows duplicate dots because your DAX measure is summing all [Volume] again at the end due to how MAX(price) behaves in that context.


    Fix it with this cleaner logic:


    CumulativeVolume =
    VAR CurrentPrice = SELECTEDVALUE('Sheet'[price])
    RETURN
    SUMX (
    FILTER (
    ALLSELECTED('Sheet'),
    'Sheet'[price] <= CurrentPrice
    ),
    [Volume]
    )


    This ensures each dot reflects cumulative volume up to its own price—no repeats at the end.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello Shahid12523, your answer is correct, it does an ascending order. But I would like a descending order when I modify your DAX code I back to the same issue...any tips ? 

       

    • Shahid12523's avatar
      Shahid12523
      Community Champion

      CumulativeVolumeDescending =
      VAR CurrentPrice = SELECTEDVALUE('Sheet'[price])
      RETURN
      SUMX (
      FILTER (
      ALLSELECTED('Sheet'),
      'Sheet'[price] >= CurrentPrice
      ),
      [Volume]
      )

      use this
      Instead of <= CurrentPrice, we use >= CurrentPrice to accumulate volumes from higher prices down to the current one.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Yes, I alrealdy did it. But it shows that..like the original issue...