Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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
Solved! Go to Solution.
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:
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")
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
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
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:
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")
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.
CustID | BkID (Values) | Created |
C1 | OnHold | 3/20/2023 |
C1 | P0 | 3/21/2023 |
C1 | P2 | 4/4/2023 |
C1 | P3 | 4/13/2023 |
C1 | P4 | 4/19/2023 |
C2 | P0 | 2/9/2023 |
C2 | P5 | 4/20/2023 |
C2 | P2 | 1/18/2023 |
C2 | P3 | 2/27/2023 |
C2 | P4 | 3/20/2023 |
C3 | OnHold | 1/12/2023 |
C3 | No Response | 4/13/2023 |
C3 | P0 | 2/27/2023 |
C3 | P3 | 3/8/2023 |
C4 | P4 | 3/28/2023 |
C5 | P0 | 1/12/2023 |
C5 | P0 | 2/9/2023 |
C5 | P2 | 1/18/2023 |
C5 | P3 | 2/27/2023 |
C5 | P3 | 2/26/2023 |
C5 | P4 | 3/20/2023 |
C5 | P4 | 3/12/2023 |
User | Count |
---|---|
117 | |
73 | |
58 | |
49 | |
48 |
User | Count |
---|---|
171 | |
122 | |
60 | |
59 | |
56 |