Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
10 months ago
Solved

DAX Help cumulative calculation

Hello - I am trying to calculate cumulative calculation, X axis = Description, Y Axis = Amount$M, Line y-axis = Cumulative %

its working fine if i select single Quarter in the Filter (callendar table) incase select multiple quarter its not working, how to sort it out.  I changed to VAR _period = VALUES('Calendar'[Quarter]) not works, suggest

Amount $M =

VAR _period = SELECTEDVALUE('Calendar'[Quarter])

RETURN
CALCULATE(SUM('Table'[Value])/1000000,
'Table'[Quarter] = _period)

 

Cumulative % =

(DIVIDE([ParetoCumulativeOrders],CALCULATE(
'Table'[Amount $M],
ALLSELECTED('Table')
)))*100


ParetoCumulativeOrders =

VAR CurrentRank = [ParetoRank]
RETURN
CALCULATE (
'Table'[Amount $M],
FILTER (
ALLSELECTED ( 'Table'[Description] ),
[ParetoRank] <= CurrentRank
)
)

ParetoRank = RANKX(
ALLSELECTED('Table'[Description]),
'Table'[Amount $M],
,
DESC,
Dense
)

 

  • hey, Anonymous 
    SELECTEDVALUE will return blank if there is more than value in current context. So you can only select single qurater if you wanna do it this way.

    If I were you, I would build the cumulative sum differently:

     



    cumulative = 
    CALCULATE(
        [Amount $M],
        'fact'[Quarter] <= MAX('fact'[Quarter])
    )

     

3 Replies

  • hey, Anonymous 
    SELECTEDVALUE will return blank if there is more than value in current context. So you can only select single qurater if you wanna do it this way.

    If I were you, I would build the cumulative sum differently:

     



    cumulative = 
    CALCULATE(
        [Amount $M],
        'fact'[Quarter] <= MAX('fact'[Quarter])
    )

     

  • v-priyankata's avatar
    v-priyankata
    Community Support

    Hi Anonymous 

    Thank you for reaching out to the Microsoft Fabric Forum Community.

    vojtechsima Thanks for the inputs.

    I hope the information provided by user was helpful. If you still have questions, please don't hesitate to reach out to the community.

     

    • v-priyankata's avatar
      v-priyankata
      Community Support

      Hi Anonymous 

      Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.