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

Calculation based on customized filter

Hi,

 

I have dataset like,

VIN NOCategoryStatus
ABC1AxilePASS
ABC1CabinPASS
ABC1EngineFAIL
DEF2AxileFAIL
DEF2CabinPASS
DEF2EngineFAIL
GHI3AxilePASS
GHI3CabinPASS
GHI3Engine

PASS

 

I want Calculation based on customized filter,

1. Distinct count of VIN where Status we need to consider only "PASS", For same VIN number we have Pass and Fail status, then we need to condider under Fail category.

For the Above the answer needs to be "PASS COUNT = 1" (I.E., FOR GHI3).

2. Top 2 defect category name ,Name of category with filter Fail.

Answer needs to be "Top 2 Defect Cat = Engine , Axile"

 

Please help me to create a DAX for this.

 

Thanks,

Mohanraj

 

@amitchandak @Jihwan_Kim 

1 ACCEPTED SOLUTION

Hi, @mogunase1 

Thank you for your feedback.

Please check the below picture and the link down below.

 

Picture1.png

 

Top2 defect category =
CONCATENATEX (
TOPN ( 2, VALUES ( Data[Category] ), [Count Fail], DESC ),
Data[Category],
", ",
[Count Fail], DESC
)
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.

All measures are in the sample pbix file.

Picture1.png

Category Measure =
SWITCH (
SELECTEDVALUE ( Slicer[Status] ),
"FAIL",
IF (
SELECTEDVALUE ( Slicer[Status] ) IN VALUES ( Data[Status] ),
"FAIL",
BLANK ()
),
"PASS",
IF (
SELECTEDVALUE ( Slicer[Status] )
IN VALUES ( Data[Status] )
&& COUNTROWS ( VALUES ( Data[Status] ) ) = 1,
"PASS",
BLANK ()
),
"select status from slicer"
)
 
VIN # Pass count =
SUMX (
VALUES ( Data[VIN NO] ),
CALCULATE ( IF ( "FAIL" IN VALUES ( Data[Status] ), 0, 1 ) )
)
 
 

https://www.dropbox.com/s/emhxbju3apwsm4m/mogunasev2.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi Jihwan,

 

For the First Question i got answer from you (Pass Count)

But for 2nd Question,

My Actual requirement is 

2. Top 2 defect category name with respect to count of Defect category ,Filter is Name of category with filter Fail needs to apply in DAX.

 

Example for above scenario - 

Top  2 Defect is,

Axile

Engine

 

Thanks,

Mohan

 

 

Hi, @mogunase1 

Thank you for your feedback.

Please check the below picture and the link down below.

 

Picture1.png

 

Top2 defect category =
CONCATENATEX (
TOPN ( 2, VALUES ( Data[Category] ), [Count Fail], DESC ),
Data[Category],
", ",
[Count Fail], DESC
)
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi,

 

Thanks a lot.

Now working fine.

 

Thanks,

Mohanraj

Hi,

Use these measures

Failed count = CALCULATE(COUNTROWS(Data),Data[Status]="Fail")
Measure = CONCATENATEX(TOPN(2,VALUES(Data[Category]),[Failed count] ),Data[Category],", ",[Failed count],DESC)

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.