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

dax - how to countrows on close date tickets based on open date filter ?

Hi,

 

I need help to create a measure for the following example :

 

Imagine I have this table (called Tickets).

 

NumberOpened dateClosed date
T101-janv01-janv
T201-janv02-janv
T302-janv04-janv
T403-janv03-janv

 

I would like to create a measure [Nb_closed_by_opened_date] that count the number of tickets (countrows) closed at a particular date provided by a pivot table filter based on the Opened date field.

 

The result I would expect with this measure woule be a pivot table like :

 

Opened dateNb_closed_by_opened_date
01-janv1
02-janv2
03-janv0

 

Can anywone help me ?

Thanks a lot !

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@OwenAuger : Thanks for sharing the Relationship link. I tried the problem mentioned and it works well. 

@oberthou : Please refer the description and screen shot attached

 

Number_count_closed_date = CALCULATE(COUNTA(Sheet2[Number]),USERELATIONSHIP(Sheet2[Closed date],Table_1[Opened date]))

Table_1 = SUMMARIZE(Sheet2,Sheet2[Opened date])

 

Steps are as follows : -

Create a new table with Open Data as mentioned above "Table_1" and a Calculated Column as "Number_count_closed_date".

Create relationship between closed data and open date , it will be (* : 1) relationship, make this active relationship

Create open date and Number_count_closed_date relationship , it will be inactive

create a table from Table_1[Opened date] and Sheet2[Number_count_closed_date]

Go to "Visual level filter" and uncheck blank to remove count of 04th Jan , as this date is NOT in Opened Date Column

Go to "Values" section and check "Show items with no data"

Make sure when you uplaod data , both the column are of Date . I ahve change the format as dd/month/yyyy . you can choose as required

Please see below the screen shotcmp.png

Hope it helps. Regards 

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@oberthou : The problem is to count closed date rows based on filter applied on opened date. 

 

Measure would look like this : 

Measure_CLosed_Date = CALCULATE(COUNTROWS(Table),ALLEXCEPT(Table,Table[Opened date]))

 

 Count_Rows.png

 

Can you please confirm , if this is what you are looking for. Thanks

 

 

 

Hi Mridul,

 

Thanks a lot but it is not what I expect. I want to count the number by closed dates but on the pivot have this based on the the open date filter by row.  Let me better explain. I also made a mistake in my exemple also ... it should look like :

 

the correct initial Table is actually :

 

berOpened dateClosed date
T101-janv01-janv
T201-janv02-janv
T302-janv02-janv
T403-janv04-janv

 

I kept your measure in the pivot table below I renamed as Nb Opened.

But the one I need is the other column "Nb_closed_by_open_date"

 

Nb_opened = CALCULATE(COUNTROWS(Table),ALLEXCEPT(Table,Table[Opened date]))

Nb_closed_by_open_date = ?  that's what I need actually ! ...

 

Opened dateNb_openedNb_closed_by_opened_date
01-janv21
02-janv22
03-janv00

 

Indeed, 01-Jan there was only 1 ticket closed (T1) and on 02-Jan there was 2 tickets closed (T2 and T3)

None were closed on 03-Jan.

 

Hope this is clearer ?

Thanks.

 

 

 

@oberthou

Have a look at this post:

Multiple Relationships Between Tables in DAX

 

In your situation you probably want an active relationship between Opened Date and your Date table, and an inactive relationship between Closed Date and your Date table.


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
Anonymous
Not applicable

@OwenAuger : Thanks for sharing the Relationship link. I tried the problem mentioned and it works well. 

@oberthou : Please refer the description and screen shot attached

 

Number_count_closed_date = CALCULATE(COUNTA(Sheet2[Number]),USERELATIONSHIP(Sheet2[Closed date],Table_1[Opened date]))

Table_1 = SUMMARIZE(Sheet2,Sheet2[Opened date])

 

Steps are as follows : -

Create a new table with Open Data as mentioned above "Table_1" and a Calculated Column as "Number_count_closed_date".

Create relationship between closed data and open date , it will be (* : 1) relationship, make this active relationship

Create open date and Number_count_closed_date relationship , it will be inactive

create a table from Table_1[Opened date] and Sheet2[Number_count_closed_date]

Go to "Visual level filter" and uncheck blank to remove count of 04th Jan , as this date is NOT in Opened Date Column

Go to "Values" section and check "Show items with no data"

Make sure when you uplaod data , both the column are of Date . I ahve change the format as dd/month/yyyy . you can choose as required

Please see below the screen shotcmp.png

Hope it helps. Regards 

 

Hi mridul, thanks for having taken time to implement the solution for me. Thanks to Owen as well for pointing us in the right direction with the separate date and ruseelationship function.

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.