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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tutuk28
Helper IV
Helper IV

Query in Dax with several conditions

Good morning!

I ask you a question, which is the best way to make this query:

 

From Table "X" I have to:
Count Number of Lines
Where Column 1 is not Empty
AND Column 3 is not "A"
AND Column 4 is not empty

And another condition is according to the type:
If "Type" is "1" has to start with A, C, E
and if "Type" is "2" he has to start with F, H, K

 

Is it possible to do this in DAX? (I think it would be quite complicated) or use the display and page filters.

Thank you!

Regards!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@tutuk28 

The first one

countrows(filter(X,not(isbalnk(X[Column 1])) && X[Column 3] <> "A" && not(isbalnk(X[Column 1]))))

Orcalculate(countrows(X),filter(X,not(isbalnk(X[Column 1])) && X[Column 3] <> "A" && not(isbalnk(X[Column 1]))))

 

Not sure where you want 2nd one and column name of start with
calculate(countrows(X),
("Type" = "1" && left(X[Column]) in {"A","C","E"})
|| ("Type" = "2" && left(X[Column]) in {"F","H","K"}))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@tutuk28 

The first one

countrows(filter(X,not(isbalnk(X[Column 1])) && X[Column 3] <> "A" && not(isbalnk(X[Column 1]))))

Orcalculate(countrows(X),filter(X,not(isbalnk(X[Column 1])) && X[Column 3] <> "A" && not(isbalnk(X[Column 1]))))

 

Not sure where you want 2nd one and column name of start with
calculate(countrows(X),
("Type" = "1" && left(X[Column]) in {"A","C","E"})
|| ("Type" = "2" && left(X[Column]) in {"F","H","K"}))

It worked! @amitchandak 

Thanks !

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.