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
CROforce
Helper I
Helper I

Count by Date using filters

Here is my sample data table called “observation” :

Capture.PNG

 

I have also created new Table called “Calendar” in Query editor which contains Date that goes from 9/30/2015 until today and I also have Index column.

Capture 1.PNG

 

“observation” and “Calendar” are related by “Date Opened” and “Date Open”.

What I am trying to do is to have a column that would show me how many items where open based on Date opened from “observation” and Date Open from “Calendar” while filtering whatever user selects from “Gating Milestone” located under “observation”.

In other words, if user selects “PVT 1” filter, calculations should show total values based on that date… Something like this:

Capture2.PNG

If user selects multiple filters like PVT 1 and DVT 1, then total should be something like this: 

Capture3.PNG

 

So far I have this formula for open: 


Open = COUNTX( FILTER ( 'observation', 'observation'[Date Opened] = 'Calendar'[Date Open] ), 'observation'[Date Opened] )

 

And this one for closed:

Closed = 
    COUNTX (
        FILTER ( 'observation', 'observation'[Date Closed] = 'Calendar'[Date Open] ),
        'observation'[Date Closed]
    )

But those always show static number and do not incorporate filtering of “Gating Milestone” … Is there a way to add filter to incorporate filtering by user selection of “Gating Milestone”?

1 ACCEPTED SOLUTION

Rather than custom formulas, have you tried the "Group By" funcitonality  within the query editor?

View solution in original post

4 REPLIES 4

Rather than custom formulas, have you tried the "Group By" funcitonality  within the query editor?

That actually worked (the filtering part)... Thank you for the help. However, when I try to create Measure to calculate "Net Open" over time period to show on the Chart, it's not giving me right number based on filters selected:

 

Here is my table (gruped by) and I have also addedd Index to this to start from 1:

Capture.PNG

 

Then I have created Messure to count Net Open overtime using the same formula as in my previous attempt which worked (but I couldn't figureouit Gating Milestone filtering):

Now calculations here are not right as you can see numbers do not match:

Capture2.PNG

 

And if I select any filter from the Gating Milestone, the numbers would be totally wrong 😞

 

This is what the chart should look like (blue line)

Capture3.PNG

 

Can you post some sample data or the PBIX for us to play with?

I have just figured it out... I had to use ALLSELECTED in my formula instead of ALL

Net OPEN = 
    CALCULATE (
        SUM ( 'Open'[Open] ) ,
        FILTER ( ALLSELECTED ( 'Open' ), 'Open'[Index] <= MAX( ( 'Open'[Index] ) )
    ))

Capture.PNG

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.