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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
PBI_newuser
Post Prodigy
Post Prodigy

How to calculate distinct count of product with criteria

Hi, I want to calculate Contract Pentration in each month with the below criteria.

  • Contract Penetration = Distinct Count of Product under Contract/Total Installs
  • If the product has contract under Warranty, do not count it for both Contracted and Install. E.g Product A is under warranty (CN-222) from Aug-2020 to Aug-2021, hence exclude Product A from the sum of "Contracted" and "Install" from Aug-2020 and Aug-2021. Include Product A in the distinct count from Aug-2021 to Aug-2022 for "Contracted" and "Install".
  • If the product has contract under Rental, exclude it from both "Contracted" and "Install". E.g Product B is include in the count for "Contracted" from Sep-2015 to May-2021 and for "Install" from May-2009 to May-2021. Exclude Product B from May-2021 to Aug-2022.
  • If the product has no contract, then count it under "Install" from the Install Date. E.g Product C is included in the count for "Install" from Aug-2021.
  • If the product has Contract Type = Demo, exclude it from calculation.
ProductContract NumberStart DateEnd DateInstall DateContract Type
ACN-11108/17/202108/16/202201/10/2019Purchased
ACN-22208/17/202008/16/202101/10/2019Warranty
ACN-33308/17/201908/16/202001/10/2019Warranty
BCN-44409/16/201505/15/202105/11/2009Purchased
BCN-55505/16/202108/31/202205/11/2009Rental
CCN-666  08/03/2021 
DCN-77712/01/201903/30/202105/09/2019Demo
ECN-88803/10/202103/09/202202/13/2021Purchased
FCN-99904/17/202004/16/202101/10/2019Warranty
FCN-00004/17/202104/16/202201/10/2019Purchased
GCN-12105/22/202105/21/202202/10/2021Purchased

 

Expected Result:

MonthContractedInstallContract Penetration %
2021-0111100%
2021-021333%
2021-032367%
2021-043475%
2021-0544100%
2021-0633100%
2021-0733100%
2021-084580%
2021-094580%
2021-104580%
2021-114580%
2021-124580%
3 REPLIES 3
lbendlin
Super User
Super User

Your expected result has month level granularity. Your source data has day level granularity. Should only complete months be considered, or should the entire month be considered even if the date may be the last day of the month? Or do you want to prorate it?

Hi @lbendlin , I wanted to count the product based on the type defined below:

  • Rental: Count the product if it has purchased any contract with contract term Rental. E.g. Product C has active "Rental" contract in 2022-02 and 2022-03. Product B has active "Warranty" in 2022-02 and hence the "Rental" contract shouldn't count here. Product B should be included in the count in 2022-03.
  • Contract: Count the product if there is any "Purchased" contract active in the month. E.g. Product H has active "Purchased" contract in 2022-02 and Product A has active "Purchased" contract in 2022-03.
  • Warranty: Count the product if there is active "Warranty" in the month. E.g. Product A has active "Warranty" in 2022-02 and has active "Purchased" contract in 2022-03. Same goes to B,D,G.
  • T&M: Count the product if they don't have contract or expired contracts. E.g. Product E has installed after 2021-02 and has no contract, it's considered T&M. Product F has expired contract in 2022-02. Product H has expired contract in 2022-03 but active contract in 2022-02. Product I is installed in 2022-03 and it has no contract.

Each product should be counted as one in each month. How to create such measure?

 

ProductTermContract Start DateContract End DateInstalled Date
APurchased02/13/202201/12/202301/10/2019
AWarranty1/13/202102/12/202201/10/2019
BRental02/23/202202/22/202605/11/2009
BWarranty02/23/202102/22/202205/11/2009
CRental05/01/202103/28/202205/09/2019
CRental09/29/202004/30/202105/09/2019
DWarranty3/31/202103/30/202205/09/2019
DPurchased3/31/202203/30/202605/09/2019
E   02/13/2021
FPurchased01/13/202101/12/202201/10/2019
FWarranty1/13/202001/12/202101/10/2019
GWarranty01/13/202103/12/202201/10/2019
HPurchased12/13/202002/12/202101/10/2019
I   03/13/2022

 

Expected Output:

Type2022-022022-03
Rental1 (C)2 (B,C)
Contract1 (H)1 (A)
Warranty4 (A,B,D,G)2 (D,G)
T&M2 (E,F)4 (E,F,H,I)

As I mentioned before your data has date level granularity but your expected result is on month level.  So this statement 

Contract: Count the product if there is any "Purchased" contract active in the month. E.g. Product H has active "Purchased" contract in 2022-02 and Product A has active "Purchased" contract in 2022-03.

is ambiguous as Product H does not have a contract for the dates in February after Feb 12. That means you cannot really show anything on month level unless you define what "in a month"  means for you. Should the whole month count even if the contract ends on the first day of the month?

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Kudoed Authors