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
Anonymous
Not applicable

Compare Report Dates to Static Date Field

I'm new to Power BI and looking to create a report that compares multiple date fields against a static date.  The fields I am looking to use are Work Request #, Initiated Date (the date the item was initiated) and Repair Date (date it was repaired).  On a given date I want to know how many work requests are outstanding.  In the example below on 1/3/2019 there would be 3 open WRs (WR#1,2 and 3), 1/4/2019 there would be 1 (WR# 1) and 1/8/2019 there would be 0.   I can't figure out how to link to a static date.

 

WR#Init DateRepair Date
11/1/20191/8/2019
21/2/20191/4/2019
31/3/20191/4/2019
41/5/20191/7/2019
51/6/20171/7/2019

 

Thank you for your help!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous you can easily achieve this by using following DAX. Add calendar table in your model and use it for slicer, don't create relatonship with this table and add following DAX to get open work orders based on selected date (if more than one date is selected then it will use MAX date)

 

# of Open WR = 
VAR __selectedDate = MAX ( 'Calendar'[Date] )
RETURN
CALCULATE (
    COUNTROWS ( 'Table (4)' ),
    
    'Table (4)'[Init Date] <= __selectedDate ,
    'Table (4)'[Repair Date] > __selectedDate ||
    'Table (4)'[Repair Date] == BLANK() 
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@Anonymous you can easily achieve this by using following DAX. Add calendar table in your model and use it for slicer, don't create relatonship with this table and add following DAX to get open work orders based on selected date (if more than one date is selected then it will use MAX date)

 

# of Open WR = 
VAR __selectedDate = MAX ( 'Calendar'[Date] )
RETURN
CALCULATE (
    COUNTROWS ( 'Table (4)' ),
    
    'Table (4)'[Init Date] <= __selectedDate ,
    'Table (4)'[Repair Date] > __selectedDate ||
    'Table (4)'[Repair Date] == BLANK() 
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k this is great and so easy to do!  Thank you for quick reply!!

amitchandak
Super User
Super User

You can connect a date dimension to different dates. One of the joins will be active others will be inactive. In the formula, you can activate based on need.

Please refer and see how to use userelation to change the date.

https://community.powerbi.com/t5/Desktop/DATE-RANGE-SLICERS-TO-COMPARE-NETSALES-OF-A-DATE-RANGE/td-p...

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Anonymous
Not applicable

@amitchandak thank you for the response!  I think @parry2k response worked better for what I'm trying to accomplish, but your post will help me with another report I'm working on!!

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.