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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
baekelal
Frequent Visitor

Count rows before current day in visual

Hi,

 

I have a table with information about incidents. For example created and solved date. That table is connected to a date table via the created date.

I have now a visual where i easly can count the created incident/per day. 

 

The problem comes with the Solved incidents. If i count the rows on the Solve date it shows solved incidents on that day but also solved incident that are solved on a later date. See Table. How can make powerbi only counts the rows where the solved (opgelost) date is equal to the date in the chart.

 

baekelal_0-1645379669133.png

See example off the bar chart.

baekelal_1-1645379791007.png

 

2nd follow up question but also related.

How can i count rows from dates before the day in the bar chart.

 

Thank in advance

 

Greetings.

 

 

1 ACCEPTED SOLUTION

@baekelal 
Now is clear. You have alot of zeros. All records with zero "Oplgelost" Date will line below any selected date. This shall solve the problem

Totaal aantal opgeloste incidenten =
VAR CurrentDate =
    MAX ( Kalender[Datum] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Incidenten' ),
        USERELATIONSHIP ( Incidenten[Opgelost], Kalender[Datum] ),
        Kalender[Datum] <= CurrentDate,
        NOT ISBLANK ( Incidenten[Opgelost] ),
        Incidenten[Opgelost] <> 0
    )

I kept the NOT ISBLANK condition incase you have blank dates. Please check and let me know

View solution in original post

12 REPLIES 12
tamerj1
Super User
Super User

Hi @baekelal 
for running total you can use the following

MesureRT =
VAR CurrentDate =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' ),
        USERELATIONSHIP ( 'Table'[Resoved Date], 'Date'[Date] ),
        'Date'[Date] <= CurrentDate
    )

and based on Incident Date

Mesure1 =
VAR CurrentDate =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' ),
        'Date'[Date] <= CurrentDate
    )

Hi again @tamerj1  and thanks alot !

 

The running total for created incidents works.

 

Only the running total for the solved incident is not correct. It starts way too high.

 

This is de Dax formula

 

Totaal aantal opgeloste incidenten =
VAR CurrentDate =
MAX ( Kalender[Datum] )
RETURN
CALCULATE (
COUNTROWS ( 'Incidenten' ),
USERELATIONSHIP ( Incidenten[Opgelost],Kalender[Datum] ),
Kalender[Datum] <= CurrentDate
)
 
It starts immediatly on 784 where it should start around 3.
 
baekelal_0-1645417405546.png

What is still wrong ?

Hi @baekelal ,
Try this

Totaal aantal opgeloste incidenten =
VAR CurrentDate =
    CALCULATE (
        MAX ( Kalender[Datum] ),
        USERELATIONSHIP ( Incidenten[Opgelost], Kalender[Datum] )
    )
RETURN
    CALCULATE (
        COUNTROWS ( 'Incidenten' ),
        USERELATIONSHIP ( Incidenten[Opgelost], Kalender[Datum] ),
        Kalender[Datum] <= CurrentDate
    )

Hi @tamerj1 ,

 

Same result. It didn't change anything.

@baekelal 
Do yu have blank dates? Try this

Totaal aantal opgeloste incidenten =
VAR CurrentDate =
    MAX ( Kalender[Datum] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Incidenten' ),
        USERELATIONSHIP ( Incidenten[Opgelost], Kalender[Datum] ),
        Kalender[Datum] <= CurrentDate,
        NOT ISBLANK ( Incidenten[Opgelost] )
    )

@baekelal 
Did you try this?

@baekelal 
Can you please share sample file?

Hi,

 

Hope 50 lines tell's enough

 

NummerGeopendOpgelost
INC001000224/01/2022 0:0024/01/2022 0:00
INC001000324/01/2022 0:0024/01/2022 0:00
INC001000624/01/2022 0:0024/01/2022 0:00
INC001000824/01/2022 0:00 
INC001001925/01/2022 0:0026/01/2022 0:00
INC001001225/01/2022 0:0025/01/2022 0:00
INC001002126/01/2022 0:0026/01/2022 0:00
INC001002426/01/2022 0:0026/01/2022 0:00
INC001002626/01/2022 0:00 
INC001003327/01/2022 0:00 
INC001004128/01/2022 0:003/02/2022 0:00
INC001003928/01/2022 0:0028/01/2022 0:00
INC001009631/01/2022 0:0018/02/2022 0:00
INC001009531/01/2022 0:0015/02/2022 0:00
INC001010031/01/2022 0:0015/02/2022 0:00
INC001005631/01/2022 0:0014/02/2022 0:00
INC001008431/01/2022 0:0014/02/2022 0:00
INC001009931/01/2022 0:0011/02/2022 0:00
INC001006731/01/2022 0:009/02/2022 0:00
INC001007331/01/2022 0:009/02/2022 0:00
INC001005731/01/2022 0:008/02/2022 0:00
INC001007231/01/2022 0:008/02/2022 0:00
INC001007931/01/2022 0:008/02/2022 0:00
INC001008831/01/2022 0:008/02/2022 0:00
INC001005831/01/2022 0:007/02/2022 0:00
INC001006431/01/2022 0:007/02/2022 0:00
INC001005531/01/2022 0:004/02/2022 0:00
INC001006531/01/2022 0:004/02/2022 0:00
INC001006931/01/2022 0:004/02/2022 0:00
INC001007731/01/2022 0:004/02/2022 0:00
INC001008931/01/2022 0:004/02/2022 0:00
INC001009231/01/2022 0:004/02/2022 0:00
INC001006031/01/2022 0:002/02/2022 0:00
INC001006631/01/2022 0:002/02/2022 0:00
INC001008331/01/2022 0:002/02/2022 0:00
INC001010431/01/2022 0:002/02/2022 0:00
INC001005031/01/2022 0:001/02/2022 0:00
INC001010331/01/2022 0:0031/01/2022 0:00
INC001004831/01/2022 0:00 
INC001004931/01/2022 0:00 
INC001005131/01/2022 0:00 
INC001005231/01/2022 0:00 
INC001005331/01/2022 0:00 
INC001005431/01/2022 0:00 
INC001005931/01/2022 0:00 
INC001006131/01/2022 0:00 
INC001006331/01/2022 0:00 
INC001006831/01/2022 0:00 
INC001007031/01/2022 0:00 

@baekelal 
Now is clear. You have alot of zeros. All records with zero "Oplgelost" Date will line below any selected date. This shall solve the problem

Totaal aantal opgeloste incidenten =
VAR CurrentDate =
    MAX ( Kalender[Datum] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Incidenten' ),
        USERELATIONSHIP ( Incidenten[Opgelost], Kalender[Datum] ),
        Kalender[Datum] <= CurrentDate,
        NOT ISBLANK ( Incidenten[Opgelost] ),
        Incidenten[Opgelost] <> 0
    )

I kept the NOT ISBLANK condition incase you have blank dates. Please check and let me know

This works !!!

 

Thanks alot.

tamerj1
Super User
Super User

Hi @baekelal 

You can create another "inactive" relationship between 'Date'[Date] and 'Table'[Resoved Date] then use 

CALCULATE ( COUNTROWS ( 'Table' ), USERELATIONSHIP ( 'Table'[Resoved Date], 'Date'[Date] ) )

the 2nd question is not clear. Are you trying to calculate the running totals?

Hi @tamerj1 ,

 

Thanks alot for this first solution. It worked like a charm!.

For my 2nd questions:

Yes i want to calculate running totals. My goals is to have the open incidents for each day.

Therefore i would like to calculate the accumulated total created incidents decreased with the accumulated total solved incidents and that for each day.

 

Does this explanation make more sence?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.