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
a4
Helper III
Helper III

Calculate the distinct count based on Status and Closed date

I have table (quotes) which has quotestatus column,createdon date column, closedon date column,quotereference column and a club year coulmn.

 

Club year logic is:   Club Year = IF(DATE(quotes[createdon].[Year],2,20)>quotes[createdon].[Date],quotes[createdon].[Year]-1,quotes[createdon].[Year])

 

Club year starts from 20th February of a particular year to 20th of Feb next year.Club year is created using created on column.

 

Now let's move to the main requirement:

 

I want to count the distinct quotereference number based on quotestatus but created date and closed on should fall under same club year. 

 

If createdon date and closedon date falls in two different club year then the distinct count of the quote will be in the club year which contains the closed date.

 

Please refer the screenshot for better understanding:

Capture4.PNG

As you can see in the above screenshot that createdon date and closedon date date falls in two different club years, so these quotes will be counted in 2019 club year because closed on date falls under 2019 club year.

 

Please find below the screenshot of entire table.

 

Capture163.PNG

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi,

 

Would you please show us your expected output more clearly?

measure =

CALCULATE (

    COUNT ( quotes[quotereference] ),

    FILTER (

        SUMMARIZE (

            quotes,

            quotes[quotereference],

            quotes[closedon],

            quotes[Club Year],

            quotes[closedon],

            quotes[quotestatus],

            "cYear", IF (

                DATE ( quotes[createdon].[Year], 2, 20 ) > quotes[closedon],

                quotes[closedon].[Year] - 1,

                quotes[closedon].[Year]

            )

        ),

        [cYear] = quotes[Club Year]

            && quotes[quotestatus] = "Declined"

    )

)

You can create measure like the measure above. It will be nice, if you can inform us more detailed information( your  data(by OneDrive for Business)) if possible for test? Then we will help you more correctly.

 

Please do mask sensitive data before uploading.

 

Thanks for your understanding and support.

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi,

 

Would you please show us your expected output more clearly?

measure =

CALCULATE (

    COUNT ( quotes[quotereference] ),

    FILTER (

        SUMMARIZE (

            quotes,

            quotes[quotereference],

            quotes[closedon],

            quotes[Club Year],

            quotes[closedon],

            quotes[quotestatus],

            "cYear", IF (

                DATE ( quotes[createdon].[Year], 2, 20 ) > quotes[closedon],

                quotes[closedon].[Year] - 1,

                quotes[closedon].[Year]

            )

        ),

        [cYear] = quotes[Club Year]

            && quotes[quotestatus] = "Declined"

    )

)

You can create measure like the measure above. It will be nice, if you can inform us more detailed information( your  data(by OneDrive for Business)) if possible for test? Then we will help you more correctly.

 

Please do mask sensitive data before uploading.

 

Thanks for your understanding and support.

 

Best Regards,

Dedmon Dai

amitchandak
Super User
Super User

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.