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
Hello all,
I've got a dataset that looks like the below:
| ID | Prog1 | Prog2 |
| 123 | SPAN | |
| 213 | ACCT | SPAN |
| 343 | FINA | |
| 593 | BSAD | ACCT |
| 994 | ACCT |
|
What I'd like to do is somehow count each instance of a Prog (regardless of Prog1 or Prog2) in a single visual. In other words, I'd like a column chart that would show SPAN as having 2 and ACCT as having 3 since they each appear in both Prog1 and Prog2 for two individuals. Or to put another way, one ID can be counted in multiple Prog counts based on the values in Prog1 and Prog2. Is there a way to combine counts from two columns in a single visual?
Solved! Go to Solution.
Hi @mljones, adding to what Greg has already suggested to you, you might want to create a separate table that contains unique values using this code:
Distinct Progr =
DISTINCT(
UNION(
DISTINCT( 'Table'[Prog1] ),
DISTINCT( 'Table'[Prog2] )
)
)
Now, we can use a single column from this new table (by default Prog1, but you can rename it with double-click) to show the distinct values of Prog1 and Prog2 together:
Now it's time for counting:
Count Progr =
VAR _CurrentlySelectedProgr = SELECTEDVALUE( 'Distinct Progr'[Prog] )
VAR _CountProgr1 =
COUNTROWS(
FILTER(
'Table',
'Table'[Prog1] = _CurrentlySelectedProgr
)
)
VAR _CountProgr2 =
COUNTROWS(
FILTER(
'Table',
'Table'[Prog2] = _CurrentlySelectedProgr
)
)
RETURN _CountProgr1 + _CountProgr2
with the following output:
To conclude:
Good luck! 🙂
Hi @mljones, adding to what Greg has already suggested to you, you might want to create a separate table that contains unique values using this code:
Distinct Progr =
DISTINCT(
UNION(
DISTINCT( 'Table'[Prog1] ),
DISTINCT( 'Table'[Prog2] )
)
)
Now, we can use a single column from this new table (by default Prog1, but you can rename it with double-click) to show the distinct values of Prog1 and Prog2 together:
Now it's time for counting:
Count Progr =
VAR _CurrentlySelectedProgr = SELECTEDVALUE( 'Distinct Progr'[Prog] )
VAR _CountProgr1 =
COUNTROWS(
FILTER(
'Table',
'Table'[Prog1] = _CurrentlySelectedProgr
)
)
VAR _CountProgr2 =
COUNTROWS(
FILTER(
'Table',
'Table'[Prog2] = _CurrentlySelectedProgr
)
)
RETURN _CountProgr1 + _CountProgr2
with the following output:
To conclude:
Good luck! 🙂
Thank you!
@mljones Typically you would unpivot those columns but you can use MC Aggregations: Multi-Column Aggregations (MC Aggregations) - Microsoft Fabric Community
Thank you!
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 44 | |
| 43 | |
| 38 | |
| 18 | |
| 16 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 30 | |
| 30 | |
| 23 |