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
Anonymous
Not applicable

non trivial DISTINCTCOUNT with multiple filters

Dear members, 

i've got some headaches with calculation which is looks easy to calculate by eyes and impossible for me to get correct result in PBI. 

 

 

Goal: to get correct claims statistics and their visualization

Sample data are located here https://dropmefiles.com/AdxlX 

Data description:

  • Presented data file contains dates of claims receving, order number, material code (SKU), investigation result and column which is explain is order taken into KPI calculation or not.
  •  investigation result is checked and resulted on SKU level: for instance, recevied claims for the order 53901 contains 6 SKUs which are confirmed or not

confirmed.JPG

 

  •  if order number is 0 that means mentioned SKUs are belong to order number which is the latest before 0: row 234 is belong to row 233 as of Order number

0 order.JPG

 

Rules for KPI calculation: 

  • KPI is calculated based on taken (column Claims taken for KPI calculation or not) and order qty (meaning: if some any of SKUs in claimed order is confirmed  then whole order is confirmed and should be calculated as  confirmed claim) per period (year, month, day)

Obstacles/headaches:

  1. how to correctly calculate it? 

using:

 

Nr of confirmed orders = CALCULATE(DISTINCTCOUNT('Sheet1'[ORDER number]);FILTER('Sheet1';'Sheet1'[ORDER number]>0&&'Sheet1'[Claim is taken for KPI calculation or not]="taken"&&'Sheet1'[Investigation result]="confirmed"))

 

Nr of NOT confirmed orders = CALCULATE(DISTINCTCOUNT('Sheet1'[ORDER number]);FILTER('Sheet1';'Sheet1'[ORDER number]>0&&'Sheet1'[Claim is taken for KPI calculation or not]="taken"&&'Sheet1'[Investigation result]="not confirmed"))

 

i have got oucome that the same order is calculated as confirmed and not confirmed due to some of its SKUs are confirmed and not confirmed (as an example above, order 53901 )

 

  1. Using Prompt page i'd like to return order numbers for the visualized table, but it shows all received claims and not only conformed or not confirmed - please advise, how to fix and where i'm wrong.

prompt.jpg

 

is it possible somehow to calculate correct results for 2 questions?

thank you in advance.

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

Hi @Anonymous ,

 

Do you mean to show "Prompt page" based on which measure you select? Tooltip will show values based on the context of current row, so I think it is impossible to do it in one table. You could create two tables with two measures in tooltip page.

Yes =
CONCATENATEX (
    CALCULATETABLE (
        DISTINCT ( Sheet1[ORDER number] ),
        FILTER ( Sheet1, 'Sheet1'[Investigation result] = "confirmed" )
    ),
    'Sheet1'[ORDER number],
    ", "
)
Not =
CONCATENATEX (
    CALCULATETABLE (
        DISTINCT ( Sheet1[ORDER number] ),
        FILTER ( Sheet1, 'Sheet1'[Investigation result] = "not confirmed" )
    ),
    'Sheet1'[ORDER number],
    ", "
)

Here is the result.

2-2.PNG

2-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

1 REPLY 1
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you mean to show "Prompt page" based on which measure you select? Tooltip will show values based on the context of current row, so I think it is impossible to do it in one table. You could create two tables with two measures in tooltip page.

Yes =
CONCATENATEX (
    CALCULATETABLE (
        DISTINCT ( Sheet1[ORDER number] ),
        FILTER ( Sheet1, 'Sheet1'[Investigation result] = "confirmed" )
    ),
    'Sheet1'[ORDER number],
    ", "
)
Not =
CONCATENATEX (
    CALCULATETABLE (
        DISTINCT ( Sheet1[ORDER number] ),
        FILTER ( Sheet1, 'Sheet1'[Investigation result] = "not confirmed" )
    ),
    'Sheet1'[ORDER number],
    ", "
)

Here is the result.

2-2.PNG

2-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

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.