Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi All,
I've been struggling to create a measure based on certain conditions as described by stakeholders.
I have two tables being used in this instance -
Table1(Fact Table)
| casekey | File type | File subtype | Other fields.... |
| 1 | Sales | *** | |
| 2 | Operations | *** | |
| 3 | General | Sales | *** |
| 4 | Sales | *** | |
| 5 | General | Operations | *** |
| 6 | General | Sales | *** |
| 7 | General | *** | |
| 8 | Operations | *** | |
| 9 | General | *** |
Dim_File_Type(DIm Table)
| File_Type |
| Sales |
| General |
| Operations |
I want to create a measure that returns a count of all files - with the caveat that files where the subtype is present count towards both the main file type and its respective subtype.
For instance, files # 3 and 6 count towards both General and Sales, and # 5 counts towards General and Operations.
So if I were to create a visual, the results should be like so -
| File_Type | # Files |
| Sales | 4 |
| General | 5 |
| Operations | 3 |
I understand that certain files will be counted twice - which is how we want the metric to behave.
Any insights on this would be greatly appreciated.
Thanks
Solved! Go to Solution.
Try a measure like the following:
# Files = COUNTROWS(FILTER('Table', 'Table'[File subtype] = SELECTEDVALUE(Dim_File_Type[File_Type]) || 'Table'[File type] = SELECTEDVALUE(Dim_File_Type[File_Type])))
Hi @13havya ,
@vicky_ nice method! Thank you, for your quick response and the solution provided.
And you can also try code as below.
# Files =
VAR File_Type = SELECTEDVALUE ( Dim_File_Type[File_Type] )
RETURN
SUMX (
'Table1',
IF (
'Table1'[File subtype] = File_Type
|| 'Table1'[File type] = File_Type,
1,
0
)
)
Result is as below.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @13havya ,
@vicky_ nice method! Thank you, for your quick response and the solution provided.
And you can also try code as below.
# Files =
VAR File_Type = SELECTEDVALUE ( Dim_File_Type[File_Type] )
RETURN
SUMX (
'Table1',
IF (
'Table1'[File subtype] = File_Type
|| 'Table1'[File type] = File_Type,
1,
0
)
)
Result is as below.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Try a measure like the following:
# Files = COUNTROWS(FILTER('Table', 'Table'[File subtype] = SELECTEDVALUE(Dim_File_Type[File_Type]) || 'Table'[File type] = SELECTEDVALUE(Dim_File_Type[File_Type])))
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 64 | |
| 56 | |
| 43 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 123 | |
| 108 | |
| 44 | |
| 32 | |
| 26 |