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
mcameron2909
Frequent Visitor

Reporting date point in time visualisation with data that has a from date and to date

Hi,

 

I'm trying to work out how to filter my data in Power BI desktop using a disconnected Reporting Date table that shows end of month reporting periods eg.

 

ReportingDate
30-Jun-20
31-Jul-20
31-Aug-20
30-Sep-20
30-Oct-20
30-Nov-20
31-Dec-20

 

And when a single reporting date is selected, have my reporting visuals on the page (grids, bar charts) adjust to show just the employees that were currently employed as at the selected reporting date.

 

Our dataset has all employee records with a StartDate and EndDate (thousands of records). A cutdown version is shown here as an example:

 

EmployeeIDEmployeeNameStateDivisionStartDateEndDate
1Joe SmithNSWIT01-Jan-2004-May-20
2Kate DowdQLDIT03-May-2008-Aug-20
3Mary BarkerQLDSales06-May-20NULL
4Tom BrownVICSales08-Sep-20NULL

 

They will be active if ReportingDate >= StartDate and ReportingDate <= EndDate

 

I've seen a similar question in a number of forums where the visuals required have been able to work on a limited number of measures, and the reponse has been to use DAX to generate a measures for each of the required reporting fields using something like this:

 

Active Employees =
var _currDate=SELECTEDVALUE('Dates'[ReportingDate])
var _employees=
FILTER(
Employee,
( ISBLANK(Employee[EndDate])
|| Employee[EndDate]>=_currDate )
&& Employee[StartDate]<=_currDate // started before that date
)
return COUNTROWS(_employees)

 

I'm not sure this is not going to work for our requirements - we need to display visuals that have a large number of fields, not just numeric measures but text fields, categories, regions. 


I've also considered using a parameter to load the model for a selected reporting date, but this doesn't provide the user experience required. 

 

Ideally we can dynamically select any reporting date and see the visuals update on set of employees that were active at that time.

 

Any help really appreciated!

 

Michael

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @mcameron2909 ,

 

You could use the following formula to create a measure:

Measure = 
IF (
    ISBLANK ( MAX ( 'Employee'[EndDate] ) )
        || MAX ( 'Employee'[StartDate] )
            <= SELECTEDVALUE ( 'Reporting Date table'[ReportingDate] )
            && MAX ( 'Employee'[EndDate] )
                >= SELECTEDVALUE ( 'Reporting Date table'[ReportingDate] ),
    1,
    0
)

And apply it to filter pane, set as "is 1" like this:

2.18.1.1.gif

Please take a look at the pbix file here.

 

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

View solution in original post

5 REPLIES 5
v-eqin-msft
Community Support
Community Support

Hi @mcameron2909 ,

 

You could use the following formula to create a measure:

Measure = 
IF (
    ISBLANK ( MAX ( 'Employee'[EndDate] ) )
        || MAX ( 'Employee'[StartDate] )
            <= SELECTEDVALUE ( 'Reporting Date table'[ReportingDate] )
            && MAX ( 'Employee'[EndDate] )
                >= SELECTEDVALUE ( 'Reporting Date table'[ReportingDate] ),
    1,
    0
)

And apply it to filter pane, set as "is 1" like this:

2.18.1.1.gif

Please take a look at the pbix file here.

 

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

Thanks Evelyn, that does exactly what I was looking for. Really appreciate your response here and the video respone, thanks!

DataInsights
Super User
Super User

Hi @mcameron2909,

 

This approach uses an indicator measure that can be used to filter a visual for only active employees. Columns and measures that are added to the visual will be filtered by the indicator measure. The disconnected table ReportingDates does not have any relationships. Let me know if this works for you.

 

Measure:

 

Active Employee Indicator = 
VAR vReportingDate =
    SELECTEDVALUE ( ReportingDates[Reporting Date] )
VAR vResult =
    SUMX (
        Employees,
        VAR vStartDate = Employees[StartDate]
        VAR vEndDate = Employees[EndDate]
        RETURN
            IF (
                ISBLANK ( Employees[EndDate] )
                    || ( vReportingDate >= Employees[StartDate]
                    && vReportingDate <= Employees[EndDate] ),
                1
            )
    )
RETURN
    vResult

 

Filter the visual:

 

DataInsights_1-1613328118302.png

 

 

DataInsights_0-1613328107771.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




See revised measure below:

 

Active Employee Indicator = 
VAR vReportingDate =
    SELECTEDVALUE ( ReportingDates[Reporting Date] )
VAR vResult =
    SUMX (
        Employees,
        VAR vStartDate = Employees[StartDate]
        VAR vEndDate = Employees[EndDate]
        RETURN
            IF (
                ISBLANK ( vEndDate )
                    || ( vReportingDate >= vStartDate
                    && vReportingDate <= vEndDate ),
                1
            )
    )
RETURN
    vResult

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for your response - Evelyn also responded with effectively the same solution, really appreciate you looking at this and coming back with the solution, looks to work, cheers.

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.