Forum Discussion
Anonymous
5 years agoNot applicable
Firstnonblank rows based on another column per group
Hi everyone, I have a situation where I need to move the value of a row to the firstnonblank row based on another column per group. In my example below, I would love to move the value of "iscom...
- 5 years ago
Anonymous,
Try these measures:
iscomplained calc = VAR vCurrentStatus = MAX ( Table2[status] ) VAR vValueBlankStatus = CALCULATE ( MAX ( Table2[iscomplained] ), ALLSELECTED ( Table2 ), VALUES ( Table2[customerno] ), Table2[status] = BLANK () ) VAR vMinStatusDate = CALCULATE ( MIN ( Table2[status date] ), ALLSELECTED ( Table2 ), VALUES ( Table2[customerno] ), NOT Table2[status] = BLANK () ) VAR vMinStatus = CALCULATE ( MIN ( Table2[status] ), ALLSELECTED ( Table2 ), VALUES ( Table2[customerno] ), Table2[status date] = vMinStatusDate ) VAR vResult = SWITCH ( TRUE (), ISBLANK ( vCurrentStatus ), BLANK (), IF ( NOT ISBLANK ( vValueBlankStatus ) && vCurrentStatus = vMinStatus, vValueBlankStatus, MAX ( Table2[iscomplained] ) ) ) RETURN vResult iscomplained final = SUMX ( VALUES ( Table2[customerno] ), [iscomplained calc] )
Anonymous
5 years agoNot applicable
Hi, thanks for your reply.
How would I adapt it, in a situation where we have a "status date"?
truly appreciate your help 🙂
DataInsights
5 years agoSuper User
Anonymous,
Would you be able to provide sample data that I can copy to Power BI, as well as the expected result?
- Anonymous5 years agoNot applicable
Hi again,
thanks again for the quick reply. I have attached a table with a sample data.., and also desired outcome
The idea would be that, the value of iscomplained, moves to the first non blank status, based on the earliest date. So for customer AA, the first non blank status is on 04-02-2020
Current situationcustomerno status status date iscomplained AA 01.02.2020 1 AA returned 06.02.2020 AA canceled 04.02.2020 AA processing 06.02.2020 BC sent 01.03.2020 1 CD sent 01.06.2020 GH Delivered 01.07.2020 1 Desired outcome
customerno status status date iscomplained AA 01.02.2020 AA returned 06.02.2020 AA canceled 04.02.2020 1 AA processing 06.02.2020 BC sent 01.03.2020 1 CD sent 01.06.2020 GH Delivered 01.07.2020 1 Appreciate it:)
- DataInsights5 years agoSuper User
Anonymous,
Try these measures:
iscomplained calc = VAR vCurrentStatus = MAX ( Table2[status] ) VAR vValueBlankStatus = CALCULATE ( MAX ( Table2[iscomplained] ), ALLSELECTED ( Table2 ), VALUES ( Table2[customerno] ), Table2[status] = BLANK () ) VAR vMinStatusDate = CALCULATE ( MIN ( Table2[status date] ), ALLSELECTED ( Table2 ), VALUES ( Table2[customerno] ), NOT Table2[status] = BLANK () ) VAR vMinStatus = CALCULATE ( MIN ( Table2[status] ), ALLSELECTED ( Table2 ), VALUES ( Table2[customerno] ), Table2[status date] = vMinStatusDate ) VAR vResult = SWITCH ( TRUE (), ISBLANK ( vCurrentStatus ), BLANK (), IF ( NOT ISBLANK ( vValueBlankStatus ) && vCurrentStatus = vMinStatus, vValueBlankStatus, MAX ( Table2[iscomplained] ) ) ) RETURN vResult iscomplained final = SUMX ( VALUES ( Table2[customerno] ), [iscomplained calc] )- Anonymous5 years agoNot applicable
This worked, Thanks alot 🙂