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
Budfudder
Helper IV
Helper IV

Slicer for Merged, Multi-Column Rows

I have two (2) tables: Invoices and Products. They look like this:

 

Invoices
InvoiceID
SalesRep

 

Products
InvoiceID
ProductID
Cost
ProductName

 

The Invoices.InvoiceID column is unique. Any invoice may have 1-n products attached to it. In the Products table, there can be any number of duplicate InvoiceIDs, each showing one ProductID (and its cost) that appeared on that Invoice.

 

Our business sells licenses to use our products (not the products themselves; just licenses). Those licenses can be renewed yearly. So in our DB, our products have names like 'Product A' and 'Product A (Renewal)'. The '(Renewal)' bit indicates that this product is actually a renewal of Product A, not the first purchase of the license. Apart from that, they are identical.

 

We need to split our invoices and their products by Renewals and non-renewals (we call it New). In the output table, we want just one row for each invoice, no matter how many products it has. It'll look like this:

 

|Invoice ID|Sales Rep|Total Cost|Renewal Products   |Renewal Cost|New Products         |New Cost|
|001       |F. Smith |      $100|Product A (Renewal)|       $100 |                     |        |
|002       |J. Blow  |      $250|Product B (Renewal)|       $150 |Product A            |    $100|
|003       |B. Bloggs|      $300|                   |            |Product C & Product D|    $300|

And so on. Note that where there are multiple products of either New or Renewal, they are concatenated. I achieved that by the DAX:

New Products = CONCATENATEX (filter(Products,
                                    Products[InvoiceID]=min(Invoices[InvoiceID]) && iserror(SEARCH("renewal", 
Products[ProductName]))),
                             Products[ProductName],
                             " & " ,
                             Products[ProductName],
                             ASC)

and I did a similar one for the Renewal products. The costs, too, add together, so that if there are multiple products of either New or Renewal, their costs add together, like for invoice 003 in the table above. Again, DAX:

New Total = SUMX(FILTER(Products,
                        Products[Invoice ID]=min(Invoices[InvoiceID]) && iserror(SEARCH("renewal", Products[ProductName]))), 
                 Products[Cost])

So far, so good. I have the table looking the way I want it. But the business wants to be able to slice the output table by New or Renewal. When they choose either, then it as if the other type of business doesn't even exist. The columns for that type of business in the output table will be empty, and the Total Cost column will show only the total cost of any items of the chosen type in the order. And if any invoice has only products of the type not chosen, that invoice will disappear from the output completely.

 

I am really struggling with this slicer, so any suggestions will be gratefully received. Thanks a lot.

1 REPLY 1
v-cherch-msft
Employee
Employee

Hi @Budfudder

 

You may try to create a new table and create a measure to link the new table with the table which you need to filter.

 

Regards,

Cherie

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.