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
konradjonsson
Helper II
Helper II

How to create a table and exclude certain row values?

I want to create a new table that include a) all SERIAL NUMBERS (unique) and b) the DATE when the serial number was first invoiced.

(this is to later on cross-reference this date with all subsequent transactions on the same serial number, e.g. spare part sales or warranties)

 

I have created a table, using a DAX-function:

SerialSoldDate = SUMMARIZE('OrderDetails';'OrderDetails'[SerialNumber];'OrderDetails'[InvoiceDate])

The result is a table that gives me all invoice dates for the specific serial number. I only want the initial sale (invoice) date.

 

There is a field called 'OrderDetails'[OrderCategory], where the value ‘2’ indicates that the transaction is the initial sale of the serial number.

I tried to use logical functions to refine the DAX function, but I could not get it to work.

 

EXAMPLE:

Origin data table

Serial Number             Invoice Date              OrderCategory

123456                   2019-05-14               2

123456                   2019-06-03               6

654444                   2019-02-17               2

654444                   2019-05-19               3

 

NEW TABLE (SerialSoldDate)

Serial Number             Sold Date

123456                   2019-05-14

654444                   2019-02-17

 

THE QUESTION

How can I create a table that includes only the invoice date of the initial sale, and not spare part sale or warranties?

1 ACCEPTED SOLUTION

Hey,

 

I do not fully understand ,,, but nevertheless maybe a simple DISTINCT around the SELECTCOLUMNS from my 1st answer is all you need, to bend the table to your will, like so:

DISTINCT(
    SELECTCOLUMNS(
    ....
    )
)

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

6 REPLIES 6
TomMartens
Super User
Super User

Hey,

 

this DAX statetement creates a table that just contains two columns the serial number and the invoice date. The DAX function FILTER is used to filter the rows where the Order Category equals 2.

Initial Sales = 
SELECTCOLUMNS(
    FILTER('Table1'
        ,'Table1'[OrderCategory] = 2
    )
    , "Serial Number" , [Serial Number]
    , "Invoice Date" , [Invoice Date]
)

You can create tables using DAX from the Menu: Modeling --> Ribbons: Calculations --> New Table

 

Please be aware that calculated tables will be only recalculated on data refresh, and not if a user changes a slicer selection.

 

Hopefully this is what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks Tom!

It is definitely one step in the right direction. There is one more requirement that I did not specify clearly in my initial question - there can be only one row per serial number, i.e. the table should have no duplicates.

 

The reason that the current table have duplicates is that the original table include several rows with the same serial number (these rows are different order line items).

 

So, I would need an addition to the DAX-function that only keeps one row per unique serial number.

 

Hey,

 

I do not fully understand ,,, but nevertheless maybe a simple DISTINCT around the SELECTCOLUMNS from my 1st answer is all you need, to bend the table to your will, like so:

DISTINCT(
    SELECTCOLUMNS(
    ....
    )
)

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Yes, now it did solve the problem!

 

Brilliant - thanks a lot!

 

/Konrad

HotChilli
Super User
Super User

Create a table by filtering the first

TableX = FILTER(Table1, Table1[OrderCategory] = 2)

Thank you.

However not what I was looking for. Perhaps my description was bit vague.

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.