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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
h11
Helper I
Helper I

Count of Project getting cancelled

Hello All, I want to know the number of projects that got cancelled with the Same Client country and client state for the last 3 months and 12 months from the date it got cancelled and when I drill through it should be able to show the complete details of each project that showed the count.

 

 FYI - I have 120+ projects that got cancelled from 2022. My table also includes Active projects. This is just a sample data with just 17 cancelled projects and 1 active project for your reference.

 

Project IDProject Cancelled dateClient CountryClient StateStatus
1Friday, February 23, 2024IndiaHyderabadCancelled
2Friday, February 23, 2024IndiaBengaluruCancelled
3Friday, April 5, 2024IndiaHyderabadCancelled
4Friday, April 14, 2023IndiaHyderabadCancelled
5Friday, March 22, 2024IndiaHyderabadCancelled
6Friday, April 1, 2022IndiaBengaluruCancelled
7Friday, August 25, 2023IndiaBengaluruCancelled
8Friday, August 25, 2023IndiaHyderabadCancelled
9Friday, December 15, 2023USAAtlantaCancelled
10Monday, April 8, 2024USAVirginaActive
11Friday, April 1, 2022USAVirginiaCancelled
12Friday, December 15, 2023USAAtlantaCancelled
13Friday, April 14, 2023IndiaHyderabadCancelled
14Friday, August 1, 2022IndiaHyderabadCancelled
15Friday, December 1, 2022IndiaHyderabadCancelled
16Friday, April 1, 2022IndiaBengaluruCancelled
17Friday, April 14, 2023IndiaBengaluruCancelled
18Friday, December 22, 2023IndiaHyderabadCancelled
1 ACCEPTED SOLUTION
v-tianyich-msft
Community Support
Community Support

Hi @h11 ,

 

I used both methods and you can check the results below:

vtianyichmsft_0-1716174199416.png

Measure = 
VAR _MINDATE = MINX(FILTER(ALL('Table'),'Table'[Client State] = MAX('Table'[Client State]) && 'Table'[Client Country] = MAX('Table'[Client Country]) && 'Table'[Status] = "Cancelled"),'Table'[Project Cancelled date])
VAR _COUNT = CALCULATE(COUNT('Table'[Project ID]),FILTER(ALLEXCEPT('Table','Table'[Client State],'Table'[Client Country]),'Table'[Status] = "Cancelled" && 'Table'[Project Cancelled date] <= EDATE(_MINDATE,6)))
RETURN
_COUNT

Measure 2 = 
var _t = ADDCOLUMNS(ALLSELECTED('Table'),"Min Date",MINX(FILTER(ALLSELECTED('Table'),[Client State]=EARLIER([Client State])&&[Client Country]=EARLIER([Client Country])&&[Status]="Cancelled"),[Project Cancelled date]))
var _t2 = ADDCOLUMNS(_t,"Count",COUNTX(FILTER(_t,[Client State]=EARLIER([Client State])&&[Client Country]=EARLIER([Client Country])&&[Status]="Cancelled"&&[Project Cancelled date]<EDATE([Min Date],6)),[Project ID]))
RETURN SUMX(FILTER(_t2,[Project ID] = MAX('Table'[Project ID])),[Count])

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

7 REPLIES 7
v-tianyich-msft
Community Support
Community Support

Hi @h11 ,

 

I used both methods and you can check the results below:

vtianyichmsft_0-1716174199416.png

Measure = 
VAR _MINDATE = MINX(FILTER(ALL('Table'),'Table'[Client State] = MAX('Table'[Client State]) && 'Table'[Client Country] = MAX('Table'[Client Country]) && 'Table'[Status] = "Cancelled"),'Table'[Project Cancelled date])
VAR _COUNT = CALCULATE(COUNT('Table'[Project ID]),FILTER(ALLEXCEPT('Table','Table'[Client State],'Table'[Client Country]),'Table'[Status] = "Cancelled" && 'Table'[Project Cancelled date] <= EDATE(_MINDATE,6)))
RETURN
_COUNT

Measure 2 = 
var _t = ADDCOLUMNS(ALLSELECTED('Table'),"Min Date",MINX(FILTER(ALLSELECTED('Table'),[Client State]=EARLIER([Client State])&&[Client Country]=EARLIER([Client Country])&&[Status]="Cancelled"),[Project Cancelled date]))
var _t2 = ADDCOLUMNS(_t,"Count",COUNTX(FILTER(_t,[Client State]=EARLIER([Client State])&&[Client Country]=EARLIER([Client Country])&&[Status]="Cancelled"&&[Project Cancelled date]<EDATE([Min Date],6)),[Project ID]))
RETURN SUMX(FILTER(_t2,[Project ID] = MAX('Table'[Project ID])),[Count])

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

v-tianyich-msft
Community Support
Community Support

Hi @h11 ,

 

I made simple samples, but not the final version because the data you provided cannot be converted to date format:

vtianyichmsft_0-1715828740423.png

Measure = var _t = ADDCOLUMNS('Table',"a",COUNTAX(FILTER(ALL('Table'),[Client State]=EARLIER([Client State])&&[Client Country]=EARLIER([Client Country])&&[Status]="Cancelled"),[Project ID]))
RETURN MAXX(_t,[a])

If you need it by date, you can try:

Measure = var _t = ADDCOLUMNS('Table',"a",COUNTAX(FILTER(ALL('Table'),[Project Cancelled date]>EOMONTH(EARLIER([Project Cancelled date]),-3)&&[Client State]=EARLIER([Client State])&&[Client Country]=EARLIER([Client Country])&&[Status]="Cancelled"),[Project ID]))
RETURN MAXX(_t,[a])

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

Hi @v-tianyich-msft : Thank you for the measure and sharing a sample file. I hope I'm almost getting there. But I'm not able to understand if this measure is for 3 months or 12 months? I need 2 measures to show cancelled projects of a client for the last 3 months count and 12 months count from the cancelled date. 

Hi @h11 ,

 

The second measure is within 3 months, if you need it within 12 months, change -3 to -12.

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

Hi @v-tianyich-msft I tried the measure you suggested for 3 months only. However, I didn't get the correct results. I'm sharing a screenshot along with the table which has date format. Please look at the screenshot and suggest the correct formula. Thank you.

h11_0-1715978291412.png

h11_1-1715979513995.png

Project IDProject Cancelled dateClient CountryClient StateStatus
12/23/2024IndiaHyderabadCancelled
22/23/2024IndiaBengaluruCancelled
34/5/2023IndiaHyderabadCancelled
414/4/2024IndiaHyderabadCancelled
53/22/2024IndiaHyderabadCancelled
64/1/2022IndiaBengaluruCancelled
78/25/2022IndiaBengaluruCancelled
88/25/2023IndiaHyderabadCancelled
912/15/2023USAAtlantaCancelled
104/8/2024USAVirginiaActive
114/1/2024USAVirginiaCancelled
1212/15/2023USAAtlantaCancelled
134/15/2024IndiaHyderabadCancelled
148/1/2022IndiaHyderabadCancelled
1512/1/2022IndiaHyderabadCancelled
164/1/2022IndiaBengaluruCancelled
174/14/2023IndiaBengaluruCancelled
1812/25/2023IndiaHyderabadCancelled
h11
Helper I
Helper I

@amitchandak Thanks for your suggestion. I didn't the required output. Please see below screenshot.

 

h11_0-1715794720553.png

I applied the measure for 3 months you suggested. I wanted to see the count of cancelled projects of clients with same name and city for last 3 months from the cancelled date. but I got all quantity as 1 each. Ideally I should get the results for feb 13th as 3 since there are 3 projets with same client name and client city for last 3 months. Same goes to 12 months of data. Thank you!

 

amitchandak
Super User
Super User

@h11 , Based on what I got, try measure like

 

Cancelled Projects Last 3 Months =
CALCULATE(
COUNTROWS('Table'),
'Table'[Status] = "Cancelled",
'Table'[Project Cancelled date] > eomonth(today(), -3)
)


Cancelled Projects Last 12 Months =
CALCULATE(
COUNTROWS('Table'),
'Table'[Status] = "Cancelled",
'Table'[Project Cancelled date] > eomonth(today(), -12)
)

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.