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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tslupphaug
Regular Visitor

Filter report by date corresponding to dates on or between two date columns

Background / setup:

I got three fact tables (data from three different Sharepoint Lists) linked up to one Date Dimension Table. I'm using a date slicer to filter my report so that I can view how many items that were created on any particular day. 

 

Problem:

For one of the fact tables, instead of showing items created per date, I'd like to view "Valid items" for any given date. Valid items will be items where the chosen date falls on or between separate columns for "Valid from" and "Valid to".

 

I'm not too experienced with Power BI, and I can't wrap my head around how this could be achieved. Hope someone can give some guidance on the matter. 🙂

 

tslupphaug_0-1674942205991.png

 

1 ACCEPTED SOLUTION

Hi, @tslupphaug 

 

You can try the following methods.

Count1 = CALCULATE(COUNT('Facts 1'[Title]),FILTER(ALL('Facts 1'),[Created]=SELECTEDVALUE('Date'[Date])))+0
Count2 =
CALCULATE ( COUNT ( 'Facts 2'[Title] ),
    FILTER ( ALL ( 'Facts 2' ),
        [Valid from] <= SELECTEDVALUE ( 'Date'[Date] )
            && [Valid to] >= SELECTEDVALUE ( 'Date'[Date] )
    )
) + 0

vzhangti_0-1675045065056.pngvzhangti_1-1675045074805.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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
Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Example data:

 

Facts 1

CreatedTitle
01-25-2023Test record 1-1
01-25-2023Test record 1-2
01-23-2023Test record 1-3
01-18-2023Test record 1-4

 

Facts 2

CreatedTitleValid fromValid to
01-25-2023Test record 2-101-25-202301-30-2023
01-25-2023Test record 2-201-25-202301-30-2023
01-22-2023Test record 2-301-22-202301-27-2023
01-18-2023Test record 2-401-19-202301-23-2023

 

DateDimensionTable

Dates
02-01-2023
01-31-2023
01-30-2023
01-29-2023
01-28-2023
01-27-2023
01-26-2023
01-25-2023
01-24-2023
01-23-2023
(and so on)

 

 

 

Report (expected result)

 

Example A

Date slicer set to: 01-25-2023

Count Facts 1 (Created on 01-25-2023): 2

Count Facts 2 (Valid on 01-25-2023): 3

 

Example B

Date slicer set to: 01-24-2023

Count Facts 1 (Created on 01-24-2023): 0

Count Facts 2 (Valid on 01-24-2023): 1

Hi, @tslupphaug 

 

You can try the following methods.

Count1 = CALCULATE(COUNT('Facts 1'[Title]),FILTER(ALL('Facts 1'),[Created]=SELECTEDVALUE('Date'[Date])))+0
Count2 =
CALCULATE ( COUNT ( 'Facts 2'[Title] ),
    FILTER ( ALL ( 'Facts 2' ),
        [Valid from] <= SELECTEDVALUE ( 'Date'[Date] )
            && [Valid to] >= SELECTEDVALUE ( 'Date'[Date] )
    )
) + 0

vzhangti_0-1675045065056.pngvzhangti_1-1675045074805.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

Yes, this is exactly the result I want. Thank you!

@v-zhangti How could I also show a table in my report with all the valid items?

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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