Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Cortana
Helper III
Helper III

How to show previous cumulative value if no value to cumulate and blank if condition applied?

I have data like this- 

IdStage DayStageNO
6g00003stage 62446
6g00003stage 5 5
6g00003stage 4214
6g00003stage 3 3
6g00003stage 2 2
6g00003stage 1 1

 

NB: Each ID has 4 stages. Every time an id will first enter stage 6, and the 5,4,3,..1. and how many days they are staying in that stage is showing on the Day column.  Here this id was in stage 6 for 244 days. It was in stage 5 but we have no data for that. Then it goes to stage 4 and stays for 21 days. this is his current stage as we don't have any future value for this ID. 


I want a cumulated column that will show the cumulative day count but like this - 

want.pngHere, as the current stage is 4, the cumulative value for stage 5 is shown as the previous value. But after stage 4,  it does not have any value in future stages. So it would be blank. 
Can anyone help me with that? 

 

5 REPLIES 5
sam_gift
Helper I
Helper I

Hi did you find the solution?

I came up with same issue

Cortana
Helper III
Helper III

Hello @Jihwan_Kim 
I think you understood what I meant but It gave me blank values when I applied this to my table. 

Hi,

If you are looking for creating a new calculated column, please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1677196643494.png

 

Cumulative days measure CC: =
VAR _minstage =
    MINX ( FILTER ( Data, Data[Day] <> BLANK () ), Data[StageNO] )
RETURN
    IF (
        Data[StageNO] >= _minstage,
        CALCULATE (
            SUM ( Data[Day] ),
            WINDOW (
                1,
                ABS,
                0,
                REL,
                SUMMARIZE ( ALL ( Data ), Data[Id], Data[Stage], Data[StageNO], Data[Day] ),
                ORDERBY ( Data[StageNO], DESC, Data[Stage], DESC ),
                KEEP,
                PARTITIONBY ( Data[Id] )
            )
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hello, @Jihwan_Kim Thank you for your response. But It does not work on mine either way. It does not show value for stage 4. I mean where there is no value for Day. Also, it is not being cumulated. 

shafiq_0-1677512190082.png

I have found another way to do that. For that I needed another column Current_stage. I thought it would be doable easily without it.

 

I used that in my calculation which gave me my the desired output. But if you have solution without using that column I will appreciated that too. 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

It is for creating a new measure.

 

Jihwan_Kim_0-1677093253845.png

 

 

Cumulative days measure: =
VAR _minstage =
    CALCULATE (
        MIN ( Data[StageNO] ),
        FILTER ( ALL ( Data ), Data[Day] <> BLANK () )
    )
RETURN
    IF (
        MAX ( Data[StageNO] ) >= _minstage
            && HASONEVALUE ( Data[StageNO] ),
        CALCULATE (
            SUM ( Data[Day] ),
            WINDOW (
                1,
                ABS,
                0,
                REL,
                SUMMARIZE ( ALL ( Data ), Data[Id], Data[Stage], Data[StageNO], Data[Day] ),
                ORDERBY ( Data[StageNO], DESC, Data[Stage], DESC ),
                KEEP,
                PARTITIONBY ( Data[Id] )
            )
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.