Value, Earlier, Allexcept ?

propi_

New Member
Joined
Jun 11, 2014
Messages
19
Hey guys,

can you help me with the following please:

I want to figuere out the first and second Order for each Customer and put it to a column.

IDCustomer_idOrder_of_n_dayOrderDayOrderstringRevenueDateOrder noCategoryFirstDayfirstOrderSecondDay1Order
11001111
2729.07.2015 00:01885689VV
S
2100212122,3629.07.2015 00:05885690FVS
3100313149,1929.07.2015 00:06885691PVS
4100414118,0229.07.2015 00:07885692FVS
51001212
108,401.09.2015 00:01885693SVS
610013132707.11.2016 00:01885694VVS
7100232360,1707.11.2016 00:05885695PVS
8100333310007.11.2016 00:06885696VVS
92001111
2729.08.2015 00:01885697XXZ
10200212122,3629.08.2015 00:05885698FXZ
1120031315029.08.2015 00:06885699PXZ
12200414118,0229.08.2015 00:07885700FXZ
13200121220001.10.2015 00:01885701ZXZ
1420013132717.11.2016 00:01885702VXZ
15200232360,1717.11.2016 00:05885703PXZ
16200333320017.11.2016 00:06885704VXZ

<tbody>
</tbody>


Thank you guy, you saved me some extra joins in SQL :)
Not sure if the DAX Engine performs faster than an SQL Statement...

Greets
Andy
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi Andy,

Just to interpret what you are wanting to calculate:

  1. For the current Customer, return he Category of the first order on the first date where that Customer placed an order.
  2. For the current Customer, return he Category of the first order on the second date where that Customer placed an order.

Using the index columns you already have, there are a few options:

Code:
[B]FirstDayFirstOrder[/B]
=
CALCULATE (
    FIRSTNONBLANK ( Data[Category], 0 ),
    ALLEXCEPT ( Data, Data[Customer_id] ),
    Data[OrderDay] = 1,
    Data[Order_of_n_day] = 1
)
or
Code:
[B]FirstDayFirstOrder[/B]
=
CALCULATE (
    FIRSTNONBLANK ( Data[Category], 0 ),
    ALLEXCEPT ( Data, Data[Customer_id] ),
    Data[OrderString] = "11"
)
or
Code:
[B]FirstDayFirstOrder[/B]
=
LOOKUPVALUE (
    Data[Category],
    Data[Customer_id], Data[Customer_id],
    Data[Orderstring], "11"
)

The SecondDayFirstOrder measure would be the same but with Data[OrderDay] = 2 or Data[OrderString] = "12"

I assume, since you are adding calculated columns, you will want to filter by these columns in your report at some point?

Regards,
Owen :)
 
Last edited:
Upvote 0
Hi Owen,

yes filter on these columns were the goal...
Man you're the best! FIRSTNONBLANK() was the key for me.
Even the LOOKUPVALUE() makes it easy though...

You've got my MVP Vote :)

Regards
Andy
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top