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
Syndicate_Admin
Administrator
Administrator

Count days in a row to 1

Good afternoon, I'm trying to count days in a row with value 1, but I can't get it right. I've tried things I've seen in the forum but I can't make it work.

ejemplo2

Image of how it would be correct:

correcto.png

Thank you, a greeting.

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Thank you very much for the help, the problem with the measure you are proposing is that it does not reset for days that have no value.

case1.PNG

In the example image you should reset the counter on days 9/01/2021 and 10/01/2021, 13/01/2021 and 14/01/2021 etc..

Really thank you for the help.

v-alq-msft
Community Support
Community Support

Hi, @Syndicate_Admin 

 

You may try the following measure to see if it helps. The pbix file is attached in the end.

Result = 
var tab =
SUMMARIZE(
    ALLSELECTED(TicajesAcumulado),
    TicajesAcumulado[empleado_id],
    TicajesAcumulado[PRESENTE],
    DimFechas[Fecha]
)
var mindate = 
    MAXX(
        FILTER(
            tab,
            [empleado_id]=MAX(TicajesAcumulado[empleado_id])&&
            [Fecha]<MAX(DimFechas[Fecha])&&
            [PRESENTE]<>1
        ),
        [Fecha]
    )
return
IF(
    MAX(TicajesAcumulado[PRESENTE])=1,
    IF(
        ISBLANK(mindate),
        COUNTROWS(
            FILTER(
                tab,
                [empleado_id]=MAX(TicajesAcumulado[empleado_id])&&
                [Fecha]>=mindate&&
                [Fecha]<=MAX(DimFechas[Fecha])
            )
        ),
        COUNTROWS(
            FILTER(
                tab,
                [empleado_id]=MAX(TicajesAcumulado[empleado_id])&&
                [Fecha]>=mindate&&
                [Fecha]<=MAX(DimFechas[Fecha])
            )
        )-1
    )
)

 

Result:

d1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

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.