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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

DAX formula for count of rows with multiple filters on columns from different tables

Hi,
I have a requirement where I need to display True/False for each SourceName, if Count of "order_id" column(coming from "Transaction" table) is > 0 then True else False, after filtering "TransactionYearMonth" from "Transaction" table in{"Jan-20","Feb-20","Mar-20"} and TransactionType'[Type]="Ticket"


Right now, it looks like this:

SaloniGupta_0-1618343880546.png

Correct Result:

SaloniGupta_1-1618343926946.png
How to add this filter?
FILTER('olap dim_TransactionType','olap dim_TransactionType'[Type]="Ticket")
in this calculated column

Flag =
var countorderid = COUNTX(
FILTER(RELATEDTABLE('olap fact_Transaction'),
'olap fact_Transaction'[TransactionYearMonth] in{"Jan-20","Feb-20","Mar-20"}),
[order_id])+0
RETURN
IF(countorderid>0,"True","False")
Also, I am trying to create this "Flag" calculation in the third table named "Client" which has the column "SourceName".
1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@Anonymous  Which table is the calculated column in? Is there a relationship between type and transaction table? Looks like it's in the transaction table?? You may not need the RELATEDTABLE function.

 

Flag =
var countorderid = COUNTX(
FILTER(RELATEDTABLE('olap fact_Transaction'),
RELATED('olap dim_TransactionType'[Type]) ="Ticket" 
&& 
'olap fact_Transaction'[TransactionYearMonth] in{"Jan-20","Feb-20","Mar-20"}),
[order_id])+0
RETURN
IF(countorderid>0,"True","False")

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

3 REPLIES 3
AllisonKennedy
Super User
Super User

@Anonymous  Which table is the calculated column in? Is there a relationship between type and transaction table? Looks like it's in the transaction table?? You may not need the RELATEDTABLE function.

 

Flag =
var countorderid = COUNTX(
FILTER(RELATEDTABLE('olap fact_Transaction'),
RELATED('olap dim_TransactionType'[Type]) ="Ticket" 
&& 
'olap fact_Transaction'[TransactionYearMonth] in{"Jan-20","Feb-20","Mar-20"}),
[order_id])+0
RETURN
IF(countorderid>0,"True","False")

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Hi @AllisonKennedy,
Thanks, this is giving the correct result and has resolved my issue.😊

@Anonymous  That's great to hear - please 'Accept as Solution' to mark the helpful post as a solution so others can find it easier and also know this post is solved. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.