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

Need help retrieve data on two data set

Hello everyone,

I have two tables, one contains all the file IDs and decision code (this table contains unique entries) and the other contains the rules that were applied to it (this one contains duplicate entries on rules and file IDs).
The two tables are linked by the file ID on which a one-to-many relationship has been established.

The second table contains duplicate entries on rules and file ID, i.e. different rules or a single rule can be applied to an ID.

I posted an example of my two tables to give you an idea.

 

What I want to do now is to get this snapshot:

I would like to count every file ID that has had one of the listed rules applied to it and has a decision code of A or R.

Please note that the rules are not static, they may change as they are updated.

# rules#file ID which one of the listed rules have been applied and have the decision code A#file ID which one of the listed rules have been applied and have the decision code B
R022  
R028  
R033  
R007  
R025  
R023  
R029  
R001  
R011  
E004  
E001  
R010  

 

Table#1 (All file ID and decision code)

File IDDecision code 
4607A
4606A
4593A
4590A
4587A
4586A
4582A
4563A
4561A
4555A
4551A
4549R
4542A
4532R
4516A

 

Table#2 (Duplicate entries)

File IDRules
4607R028
4606R022
4606R007
4593R022
4590R023
4587R022
4586R025
4582R022
4563R028
4563R033
4561R022
4561R033
4561R007
4561R025
4555R025
4551R022
4551R028

 

I tried all the possibilities that I know of DAX but I had no solutions.

Thank you in advance for your precious help.

 

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @FranckGbadamass 

If you want to use matrix to display the count, you can take the method mentioned by AlexisOlson, it's the fastest way. 

If you don't want to use matrix or you just want to know how to calculate the count by DAX, try measures bellow,

code A = 
    var  _t0=SUMMARIZE(FILTER(ALL(Table2),Table2[Rules]=MIN(Table2[Rules])),[File ID])
    var  _t1=SUMMARIZE(FILTER(ALL(Table1),Table1[Decision code] ="A"),[File ID])
    var  _t2=INTERSECT(_t1,_t0)
return COUNTROWS(_t2)
code R = 
    var  _t0=SUMMARIZE(FILTER(ALL(Table2),Table2[Rules]=MIN(Table2[Rules])),[File ID])
    var  _t1=SUMMARIZE(FILTER(ALL(Table1),Table1[Decision code] ="R"),[File ID])
    var  _t2=INTERSECT(_t1,_t0)
return COUNTROWS(_t2)

result

vxiaotang_0-1638513752280.pngvxiaotang_2-1638513831746.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @FranckGbadamass 

If you want to use matrix to display the count, you can take the method mentioned by AlexisOlson, it's the fastest way. 

If you don't want to use matrix or you just want to know how to calculate the count by DAX, try measures bellow,

code A = 
    var  _t0=SUMMARIZE(FILTER(ALL(Table2),Table2[Rules]=MIN(Table2[Rules])),[File ID])
    var  _t1=SUMMARIZE(FILTER(ALL(Table1),Table1[Decision code] ="A"),[File ID])
    var  _t2=INTERSECT(_t1,_t0)
return COUNTROWS(_t2)
code R = 
    var  _t0=SUMMARIZE(FILTER(ALL(Table2),Table2[Rules]=MIN(Table2[Rules])),[File ID])
    var  _t1=SUMMARIZE(FILTER(ALL(Table1),Table1[Decision code] ="R"),[File ID])
    var  _t2=INTERSECT(_t1,_t0)
return COUNTROWS(_t2)

result

vxiaotang_0-1638513752280.pngvxiaotang_2-1638513831746.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-xiaotang

AlexisOlson
Super User
Super User

It seems like you can put it in a matrix with Rules on Rows and Decision Code on column and take the distinct count of File ID for the measure:

AlexisOlson_0-1638307279014.png

 

If you had something else in mind, please share what your expected result should be.

Sooorry guys if I mentioned you 🙏

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.