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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ducky
Helper I
Helper I

Paginated Reports (report builder) - select only records between dates

Hi all,

 

New on paginated reports. 

heres my situation - got a model published on services. I connect to that dataset with PBI Report builder. 

I have a employee table looking like this: 

Employee Idstart dateend datecompany id
A1231/1/20211/31/2021bla
A1232/1/20215/1/2021bla
B1115/2/20211/31/2022bla
B1112/1/20215/1/2021bla
    

 

my table contains the historised employee data where periods are not overlapping. 

I want to have a parameter that user can select a date and I pass this parameter in my query and select only the record of each employee that is in that period (eg: date selector: 2/15/2021 would give 2nd record of each employee)

 

I've made this query but for some reason it doesnt work. 

EVALUATE
SUMMARIZECOLUMNS(
'employee'[company_id],
'employee'[department],
'employee'[employee_name],
'employee'[employee_id],
'employee'[start_dt],
'employee'[end_dt],
FILTER( 'employee',
@date_selector >= Format('employee'[start_dt],"yyyy-mm-dd") && @date_selector <= FORMAT('employee'[END_DT],"yyyy-mm-dd") ))
ORDER BY
'employee'[company_id] ASC

 

Any ideas ? or maybe some direction where I could find an answer? 

 

PS: I've been trying other methods and searching online but no satisfactory results( some due performance) 

1 ACCEPTED SOLUTION
ducky
Helper I
Helper I

@Sahir_Maharaj  - Thanks for your suggestions. However I was more looking for a practical approach to solving my issue. 

Here's what I finally made out to work using DAx studio - only pasting the filtering solution. 

     FILTER(
     VALUES('employee'[END_DT])
      @date_selector <= 'employee'[END_DT]
    ),
    FILTER(
     VALUES('employee'[START_DT])
      @date_selector >= 'employee'[START_DT]
    )
    )

View solution in original post

2 REPLIES 2
ducky
Helper I
Helper I

@Sahir_Maharaj  - Thanks for your suggestions. However I was more looking for a practical approach to solving my issue. 

Here's what I finally made out to work using DAx studio - only pasting the filtering solution. 

     FILTER(
     VALUES('employee'[END_DT])
      @date_selector <= 'employee'[END_DT]
    ),
    FILTER(
     VALUES('employee'[START_DT])
      @date_selector >= 'employee'[START_DT]
    )
    )

Sahir_Maharaj
Super User
Super User

Hello @ducky,

 

Here are some suggestions:

 

1. Ensure that the format of the date parameter @date_selector matches the format of the start_dt and end_dt columns in the 'employee' table.

 

2. Verify that the date comparison in the FILTER function is evaluating correctly. Instead of using the FORMAT function within the FILTER, you can directly compare the dates. Here's the adjusted query:

 

EVALUATE
SUMMARIZECOLUMNS(
    'employee'[company_id],
    'employee'[department],
    'employee'[employee_name],
    'employee'[employee_id],
    'employee'[start_dt],
    'employee'[end_dt],
    FILTER(
        'employee',
        @date_selector >= 'employee'[start_dt] && @date_selector <= 'employee'[end_dt]
    )
)
ORDER BY 'employee'[company_id] ASC

 

3. Ensure that there is a proper relationship established between the 'employee' table and any other relevant tables.

 

Should you require further details or assistance please do not hesitate to reach out to me.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors