Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register 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])))
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 44 | |
| 43 | |
| 38 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 67 | |
| 66 | |
| 31 | |
| 28 | |
| 24 |