Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
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,
A strange one, I have the following table:
| CustomerID | Product Name | Customer Status |
| 1001 | Laptop | Active |
| 1002 | Smartphone | Inactive |
| 1003 | Tablet | Active |
| 1004 | Active | |
| 1005 | Headphones | Inactive |
| 1001 | Active | |
| 1006 | Active | |
| 1007 | Keyboard | Active |
| 1008 | Mouse | Inactive |
| 1009 | Laptop | Active |
| 1001 | Mouse | Active |
And I want to use a Power BI table to display this information, but with a filter so that if the product name is available it will show, but if not, it will provide a blank row - BUT if there's a product, do not show a blank row.
So, the output would be
| CustomerID | Product Name | Customer Status |
| 1001 | Laptop | Active |
| 1001 | Mouse | Active |
| 1002 | Smartphone | Inactive |
| 1003 | Tablet | Active |
| 1004 | Active | |
| 1005 | Headphones | Inactive |
| 1006 | Active | |
| 1007 | Keyboard | Active |
| 1008 | Mouse | Inactive |
| 1009 | Laptop | Active |
So as you can see the blank row for 1001 has been removed, but the other customers who have blank but no other product details remain.
How would you approach this? Would it be best to approach it by providing a comparison between MembershipID and Product Name and then if certain values are met it returns the product, or the blank row? Also note that the CustomerID could appear more than once for orders with different products and I would like this to be on different rows as opposed to amalgamated.
Thanks for any pointers!
Solved! Go to Solution.
Create a Calculated Column
ShowRow =
IF(
'Table'[Product Name] <> BLANK() ||
COUNTROWS(
FILTER(
'Table',
'Table'[CustomerID] = EARLIER('Table'[CustomerID]) &&
'Table'[Product Name] <> BLANK()
)
) = 0,
1,
0
)
Add the calculated column ShowRow to your table.
Apply a filter on the visual: ShowRow = 1.
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Hi @SeniorJunior ,
Add a calculated column in your data model to flag the rows you want to filter out. Use the following DAX formula:
IsRowToShow =
VAR CurrentCustomerID = 'Table'[CustomerID]
VAR HasNonBlankProduct =
CALCULATE(
COUNTROWS('Table'),
'Table'[CustomerID] = CurrentCustomerID,
NOT(ISBLANK('Table'[Product Name]))
)
RETURN
IF(
ISBLANK('Table'[Product Name]) && HasNonBlankProduct > 0,
FALSE,
TRUE
)
Once the column is created, apply a visual-level filter by dragging the IsRowToShow column to the filter pane and set the filter to show only rows where IsRowToShow is TRUE
Create a Calculated Column
ShowRow =
IF(
'Table'[Product Name] <> BLANK() ||
COUNTROWS(
FILTER(
'Table',
'Table'[CustomerID] = EARLIER('Table'[CustomerID]) &&
'Table'[Product Name] <> BLANK()
)
) = 0,
1,
0
)
Add the calculated column ShowRow to your table.
Apply a filter on the visual: ShowRow = 1.
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Perfect - just what I needed!
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 |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |