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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sivarajan21
Helper V
Helper V

Relationship issue when Calendar table filtering two date columns in fact table

Hi,

 

I have a model where Calendar table filters communication table as below:

sivarajan21_0-1697176984016.png

Here Calendar table Date column should filter communication table  Created_on and Closed_on (both columns) as highlighted above. So I established one active relationship(between calendar Date to Communication Created_on date column)  and one inactive relationship(between calendar Date to Communication Closed_on date column). But I am not sure whether it is correct or not.

 

My end goal is create a visual like below that shows the trend of Created_on and Closed_on over calendar dates.

sivarajan21_1-1697177349107.png

So I created two dax measures named Open Queries and Closed Queries:

Open Queries =
COUNTBLANK ( Communications[Closed_On] )

 

Closed Queries =
CALCULATE (
( COUNT ( Communications[Closed_On] ) ),
Communications[Closed_On] <> BLANK ()
)

 

But the resulting count in visual doesn't match with the data in data view for communication table

Is there any issue with my relationships or dax? I am confused and its bothering for for a couple of days now.

Because when I remove calendar date from visual, the counts are matching with data view:

sivarajan21_2-1697179643221.png

 

The expected out come is when using calendar date month, days, and year to filter above measures, the count should match the data in data view.

 

PFA files here Communications 4 (1).pbix

Please let me know if you need further details

 

Thanks in advance!

@Ahmedx @Greg_Deckler @amitchandak @Ashish_Mathur @marcorusso 

1 ACCEPTED SOLUTION

It depends on what you want.
You have two dates, which means that a query is open in all the days between open and close. If you want to be able to count that in any date, use this pattern: Events in progress – DAX Patterns

If you want to count how many queries were opened and closed in a day/month/quarter (regardless of when they have been closed), you should write:

Opened Queries = COUNTROWS ( Communications )
Closed Queries =
CALCULATE (
    COUNTROWS ( Communications ),
    USERELATIONSHIP ( Communications[Closed_On], Calendar[Date] ),
    KEEPFILTERS ( NOT ISBLANK ( Communications[Closed_On] ) )
)

 

View solution in original post

2 REPLIES 2

It depends on what you want.
You have two dates, which means that a query is open in all the days between open and close. If you want to be able to count that in any date, use this pattern: Events in progress – DAX Patterns

If you want to count how many queries were opened and closed in a day/month/quarter (regardless of when they have been closed), you should write:

Opened Queries = COUNTROWS ( Communications )
Closed Queries =
CALCULATE (
    COUNTROWS ( Communications ),
    USERELATIONSHIP ( Communications[Closed_On], Calendar[Date] ),
    KEEPFILTERS ( NOT ISBLANK ( Communications[Closed_On] ) )
)

 

@marcorusso 

 

Dear Sir,

 

Thank you so much for your help with this beautiful solution!

Wow! this is best solution I would have asked for and many thanks!

I apologize for the delayed response and I appreciate your patience!

 

The reason for delay is I wanted to test the report fully so that it did not cause any issues later on.

Your guidance has really helped me resolve the doubts.

 

I found your explanation on Events in progress – DAX Patterns very insightful.

If there's anything I can assist you with in the future, please don't hesitate to ask.

Thanks again for your support, it means a lot to me.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.