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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

summarize all rows on a given date based on their status for each row.

Hi!

 

I have a tricky challenge in my hands and would be grateful for any help provided.


My datasheet is like this.

IDStatus       Start Date1              End Date2                 
1Offline2020-01-012020-01-25
2Online2020-01-02null
3Offline2020-01-282020-02-25
4Offline2020-01-282020-05-20

 

I want to summarize like this:

IDsum online at start date          sum offline at start date           
113
222
331
431

 

So basically I want to summarize all rows on a given date based on their status for each row.

 

Trying to figure out a method to do this, maybe convert the date to number of days and then use range? Is there a good method for doing this?

 

Please tell me if you need more clarification. 

 

 

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

I know this is the Power Query forum, but I'd say you really want to use DAX for this.

 

Assuming that an 'Online' item isn't presumed to be so by exception of it not being 'Offline', then this should work:

 

1) Set up a calendar dimension table either in PQ (recommended) or DAX, whatever works for you.

2) Create a measure something like this:

_onlineAtDate =
VAR __cDate = MAX(calendar[date])
RETURN
CALCULATE(
  COUNT(yourTable[ID]),
  yourTable[Status] = "Online".
  FILTER(
    yourTable,
    yourTable[Start Date1] <= __cDate
    && (yourTable[End Date2] >= __cDate
      || ISBLANK(yourTable[End Date2]))
  )
)

 

Put this in a visual with calendar[date] and it should do what you want.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

I know this is the Power Query forum, but I'd say you really want to use DAX for this.

 

Assuming that an 'Online' item isn't presumed to be so by exception of it not being 'Offline', then this should work:

 

1) Set up a calendar dimension table either in PQ (recommended) or DAX, whatever works for you.

2) Create a measure something like this:

_onlineAtDate =
VAR __cDate = MAX(calendar[date])
RETURN
CALCULATE(
  COUNT(yourTable[ID]),
  yourTable[Status] = "Online".
  FILTER(
    yourTable,
    yourTable[Start Date1] <= __cDate
    && (yourTable[End Date2] >= __cDate
      || ISBLANK(yourTable[End Date2]))
  )
)

 

Put this in a visual with calendar[date] and it should do what you want.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.