The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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 |
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
77 | |
71 | |
48 | |
41 |
User | Count |
---|---|
137 | |
108 | |
69 | |
64 | |
58 |