cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jereaallikko
Helper II
Helper II

Help with if Function in DAX

Hi all,

 

I am trying to show number of actions needed for my team. The idea is to create a DAX (or custom column if needed) to show number of items where some actions are needed.

 

Data table illustrated as below:

 

jereaallikko_0-1618936432958.png

 

Here are the rules:

 

Main rule is: Only from items where

  • Status = "Open" or "Cancelled" or "Pending"

Additionally:

  • Information Request Status = "Waiting"
  • Group = "Sales"

So based on the table below, the measure should show 3 actions needed:

 

jereaallikko_1-1618936808471.png

(On 1st row no action needed, because "Status" does not match the main rule)

 

Any tips for the issue? If more information is needed, don't hesitate to ask.

 

Br

 

Jere Aallikko

 

 

 

1 ACCEPTED SOLUTION
ERD
Solution Supplier
Solution Supplier

Hi @jereaallikko ,

Try this measure:

#CountItems = 
COUNTAX(FILTER(T, T[Status] IN {"Pending","Open","Cancelled","Closed"} && OR(T[InfStatus] = "Waiting", T[Group] = "Sales")), T[ID])

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

5 REPLIES 5
jereaallikko
Helper II
Helper II

Hi @ERD 

 

One more question regarding the issue.

 

How should I mofidy the measure if I want to add more conditions?

 

Just as an example:

All the previous conditions + action needed when Handler = Jake? or ID = 578344

 

I tried to add conditions to the measure as below, but it is giving error.

COALESCE(
COUNTAX(FILTER(T, T[Status] IN {"Pending","Open","Cancelled","Closed"} && OR(T[InfStatus] = "Waiting", T[Group] = "Sales", T[Handler] = "Jake", T[ID] = "578344")), T[ID]),
0)

 

Thanks in advance,

 

Jere

ERD
Solution Supplier
Solution Supplier

@jereaallikko ,

You need to use Or (||) operator in this case. https://dax.guide/op/or/ 

ERD
Solution Supplier
Solution Supplier

Hi @jereaallikko ,

Try this measure:

#CountItems = 
COUNTAX(FILTER(T, T[Status] IN {"Pending","Open","Cancelled","Closed"} && OR(T[InfStatus] = "Waiting", T[Group] = "Sales")), T[ID])

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

Hi @ERD 

 

That worked out well! One more question:

 

Is there a way to modify the measure, that if there are no actions needed, the result will show as 0? Now it shows as "blank". I am using Card as a visual.

 

Thanks in advance.

 

-Jere

ERD
Solution Supplier
Solution Supplier

@jereaallikko ,

#CountItems = 
COALESCE(
COUNTAX(FILTER(T, T[Status] IN {"Pending","Open","Cancelled","Closed"} && OR(T[InfStatus] = "Waiting", T[Group] = "Sales")), T[ID]),
0)

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors