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
rixmcx59
Helper IV
Helper IV

Get all Phases for a customer

Hello all, can't get the right result, I need to identify customers that have completed or are in phase P0, P2, P3 and P4. I need the if statement to return "On" if all the variables are true.

OnNot =
var P0 = IF(CALCULATE(COUNT(FactTable[CustID]),FILTER(ALLEXCEPT(FactTable,FactTable[CustID]),FactTable[BkID] = "P0"))>0,TRUE(),FALSE())
var P2 = IF(CALCULATE(COUNT(FactTable[CustID]),FILTER(ALLEXCEPT(FactTable,FactTable[CustID]),FactTable[BkID] = "P2"))>0,TRUE(),FALSE())
var P3 = IF(CALCULATE(COUNT(FactTable[CustID]),FILTER(ALLEXCEPT(FactTable,FactTable[CustID]),FactTable[BkID] = "P3"))>0,TRUE(),FALSE())
var P4 = IF(CALCULATE(COUNT(FactTable[CustID]),FILTER(ALLEXCEPT(FactTable,FactTable[CustID]),FactTable[BkID] = "P4"))>0,TRUE(),FALSE())
RETURN
CALCULATE(IF(P0=TRUE() && P2=TRUE() && P3=TRUE() && P4=TRUE(),"On","Not"))

 

Thanks

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

Hi, @rixmcx59 

According to your description, you want to falg the CustID to "On" or "Not" by the [CustID] has all "P0,P2,P3,P4".

I have no sample data for your case so i create a sample data for it , the test data is as follows:

vyueyunzhmsft_0-1683769721555.png

If you want to use a measure you can use this dax code:

Measure = var _b  =VALUES('Table'[BkID])
return
IF({"P0"} in _b &&{"P2"} in _b&&{"P3"} in _b&&{"P4"} in _b,"ON" , "NOT")

vyueyunzhmsft_1-1683769990979.png

 

If you want to use a calculated column , you can use this dax code:

Column = var _b =SELECTCOLUMNS( FILTER('Table','Table'[CustID] = EARLIER('Table'[CustID])) , "b" , [BkID])
return
IF({"P0"} in _b &&{"P2"} in _b&&{"P3"} in _b&&{"P4"} in _b,"ON" , "NOT")

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

3 REPLIES 3
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

v-yueyunzh-msft
Community Support
Community Support

Hi, @rixmcx59 

According to your description, you want to falg the CustID to "On" or "Not" by the [CustID] has all "P0,P2,P3,P4".

I have no sample data for your case so i create a sample data for it , the test data is as follows:

vyueyunzhmsft_0-1683769721555.png

If you want to use a measure you can use this dax code:

Measure = var _b  =VALUES('Table'[BkID])
return
IF({"P0"} in _b &&{"P2"} in _b&&{"P3"} in _b&&{"P4"} in _b,"ON" , "NOT")

vyueyunzhmsft_1-1683769990979.png

 

If you want to use a calculated column , you can use this dax code:

Column = var _b =SELECTCOLUMNS( FILTER('Table','Table'[CustID] = EARLIER('Table'[CustID])) , "b" , [BkID])
return
IF({"P0"} in _b &&{"P2"} in _b&&{"P3"} in _b&&{"P4"} in _b,"ON" , "NOT")

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Thanks Aniya for your DAX and your guess at my data was accurate. A sample of my data below, there are duplicates due to the edits on other columns than Bk change.

 

CustIDBkID (Values)Created
C1OnHold3/20/2023
C1P03/21/2023
C1P24/4/2023
C1P34/13/2023
C1P44/19/2023
C2P02/9/2023
C2P54/20/2023
C2P21/18/2023
C2P32/27/2023
C2P43/20/2023
C3OnHold1/12/2023
C3No Response4/13/2023
C3P02/27/2023
C3P33/8/2023
C4P43/28/2023
C5P01/12/2023
C5P02/9/2023
C5P21/18/2023
C5P32/27/2023
C5P32/26/2023
C5P43/20/2023
C5P43/12/2023

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.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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