Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Rsanjuan
Helper IV
Helper IV

Creating a measure with multiple conditions

I am looking to calculate # of bids, when Job Phase equals certain conditions.  How do we do it for more than one condition?

 

NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),Master[Job.Job_Phase__c]="closed")

 

For example, I want to include not only "closed" but "in process", "confirmed"

 

Thanks!

2 ACCEPTED SOLUTIONS

check that the calculated colum is working as expected. Without seeing more of the model its hard to see whats wrong. 

 

 

//if this is a solution please mark as such

// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

v-caliao-msft
Employee
Employee

Hi @Rsanjuan,

 

You can use the follow DAX expression to get your expected result.
Count = CALCULATE(DISTINCTCOUNT(Master[ID]),FILTER(ALL(Master),Master[Job.Job_Phase__c]="closed"||Master[Job.Job_Phase__c]="in process"||Master[Job.Job_Phase__c]="confirmed"))

 

Capture.PNG

 

 

Regards,

Charlie Liao

 

 

View solution in original post

23 REPLIES 23
Anonymous
Not applicable

I want to count in datset if NCR status is "Open" and Proposed Action Status, please help

 

Open & Accepted = CALCULATE(COUNT(NCR[NCR Closeout Status]),NCR[NCR Closeout Status]="Open"&& NCR[Proposed Action Status]="Accepted"))

Thanks Bro.. This was solved my requirement...😀

 

Hi,

 

I do not see any mistake in your formula.  What problem are you facing?


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

The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression.

Hi,

 

If you replace && with a comma, does the formula work?  If not, then share the link from where i can download your PBI file.


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

Please help,

 

I want Calculated Row for No of Shop Drawings with Rev 0, 1 , 2 , 3 submitted by Subcontractor, The formula I used is working fine in while creating measure but its not working when I am creating calculated column

 

Calculated Column = CALCULATE (COUNT('Shop Drawings'[Subcontractor]),'Shop Drawings'[Subcontractor]="ACCESS 1", 'Shop Drawings'[Rev]="0")

 

 

Subcontractor

Revo 0

Rev 1

Rev 2

Rev 3

ACCESS 1

2

3

1

0

Hi,

 

Share the source dataset.  The table that you have pasted in your message looks like the result you are expecting.


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

SlDrawing NumberRevPlot Zone CodeShop Drawing TitleLevel Zone DisciplineSubcontractorTransmittal ReferenceSubmission Date PlannedSubmission Date Actual Due DateActualOverdueApproval StatusLatest / SupersededApproval Ref. No.
                  
16004-0100-ACS-1112-SO-100000100Typical Car Park Rubber Accessories Details  Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-0160477-Nov-1514-Nov-1521-Nov-155-Dec-1514Bsuperseded6004-MLD-TRANSMIT-020768
26004-0100-ACS-1112-SO-100010100Typical Car Park Rubber Accessories Details  Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-040040 24-Mar-1631-Mar-1631-Mar-160BLatest6004-MLD-TRANSMIT-042535
36004-0100-ACS-1112-SO-100100100Car Park Accessory setting out. Basement 2. ZONE 3 Zone 3Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-0184207-Nov-1525-Nov-152-Dec-155-Dec-153Bsuperseded6004-MLD-TRANSMIT-020732
46004-0100-ACS-1112-SO-100110100Car Park Accessory setting out. Basement 2. ZONE 3 Zone 3Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-062382 25-Sep-162-Oct-1615-Oct-1613BLatest6004-MLD-TRANSMIT-065308
56004-0100-ACS-1112-SO-100200100Car Park Accessory setting out. Basement 2. ZONE 2 Zone 2Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-0160487-Nov-1514-Nov-1521-Nov-155-Dec-1514BLatest6004-MLD-TRANSMIT-020765
66004-0100-ACS-1112-SO-100300100Car Park Accessory setting out. Basement 2. ZONE 3 Zone 3Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-0160507-Nov-1514-Nov-1521-Nov-155-Dec-1514Bsuperseded6004-MLD-TRANSMIT-020749
76004-0100-ACS-1112-SO-100310100Car Park Accessory setting out. Basement 2. ZONE 3 Zone 3Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-062385 25-Sep-162-Oct-1615-Oct-1613BLatest6004-MLD-TRANSMIT-065305
86004-0100-ACS-1112-SO-100400100Car Park Accessory setting out. Basement 2. ZONE 4 Zone 4Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-01605114-Nov-1514-Nov-1521-Nov-155-Dec-1514Bsuperseded6004-MLD-TRANSMIT-020752
96004-0100-ACS-1112-SO-100410100Car Park Accessory setting out. Basement 2. ZONE 4 Zone 4Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-062393 25-Sep-162-Oct-1615-Oct-1613BLatest6004-MLD-TRANSMIT-065307
106004-0100-ACS-1112-SO-100500100Car Park Accessory setting out. Basement 2. ZONE 5 Zone 5Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-01605214-Nov-1514-Nov-1521-Nov-155-Dec-1514BLatest6004-MLD-TRANSMIT-020753
116004-0100-ACS-1112-SO-100600100Car Park Accessory setting out. Basement 2. ZONE 6 Zone 6Architectural/CORNER GUARDSACCESS 16004-ALE-TRANSMIT-01605314-Nov-1514-Nov-1521-Nov-155-Dec-1514BLatest6004-MLD-TRANSMIT-020755

Hi,

 

In a Matrix visual, drag Contractor to row labels and Rev to column labels.  Write thie measure

 

=COUNTORWS(Data)


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

Thanks its working

Anonymous
Not applicable

Thanks Ashish,

 

Its working now, repplace && by Cooma and its working

Hi,

 

If my reply helped, please mark it as Answer.


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

How can the result (15 in this case) be sliced versus shown as a static number?

v-caliao-msft
Employee
Employee

Hi @Rsanjuan,

 

You can use the follow DAX expression to get your expected result.
Count = CALCULATE(DISTINCTCOUNT(Master[ID]),FILTER(ALL(Master),Master[Job.Job_Phase__c]="closed"||Master[Job.Job_Phase__c]="in process"||Master[Job.Job_Phase__c]="confirmed"))

 

Capture.PNG

 

 

Regards,

Charlie Liao

 

 

samdthompson
Memorable Member
Memorable Member

Hi, the cool thing about calculate is you can put multiple filters after it so:

 

NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),

filter(Master[Job.Job_Phase__c])="closed",

filter(table[1])="condition1",

filter(table[2])="condition2",

filter(table[n])="condition_n")

 

should do the job for you.

 

 

//if this is a solution please mark as such.

// if this is a solution please mark as such. Kudos always appreciated.

@samdthompson

 

It seemed to not work. I entered this:

 

NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),Master[Job.Job_Phase__c]="closed",filter(Master, Master[Job.Job_Phase__c]="confirmed"))

 

Those conditions are all under the same table and same field "Job Phase".  Am I doing something wrong?

try this:

 

NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),

filter(Master[Job.Job_Phase__c])="closed",

filter(Master, Master[Job.Job_Phase__c])="confirmed")

 

 

// if this is a solution please mark as such

// if this is a solution please mark as such. Kudos always appreciated.

@samdthompson

 

It seemed to not work either.  Is there a way, I can just do a "Not equal"?  There is only one field that we cannot consider for job phase.

I am bit confused as to why it would not work. i guess you could do a calculated column

 

= if(and(Master[Job.Job_Phase__c]="closed",Master, Master[Job.Job_Phase__c]="confirmed"),1,0)

 

and then do :

 

NumberofSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),filter(Master[calculated column])="1"))

 

 

//if this is a solution please mark as such

// if this is a solution please mark as such. Kudos always appreciated.

@samdthompson

 

I did this:

 

ConditionSales = if(and(Master[Job.Job_Phase__c]="closed",Master[Job.Job_Phase__c]="confirmed"),1,0)

 

then did this:

 

NoOfSales = Calculate(DISTINCTCOUNT(Master[Bid_Number__c]),Master[ConditionSales]="1")

 

When I try to put it into a card visual, I get this error:

 

Error Message:

MdxScript(Model) (1, 83) Calculation error in measure 'Master'[NoOfSales]: DAX comparison operations do not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

 

 

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.