Dan Yuncken
New Member
- Joined
- Nov 24, 2013
- Messages
- 3
Hi everyone,
I have a DAX question I’m having trouble finding an answer for in this forum. I’ve found some good answers on cumulative totals but nothing that will work in the context I need it in.
I have a sales table linked to three dimension tables: date table (Sale Table Key: Invoice Date), customer table (Sale Table Key: Outlet Number) and product table (Sale Table Key: Product number).
I need a table with two calculated fields ('Sum of Actual Cases' &'Purchase Number') as follows:
[TABLE="width: 415"]
<tbody>[TR]
[TD="width: 132"]Invoice Date
[/TD]
[TD="width: 108"]Product Number[/TD]
[TD="width: 96"]Outlet Number[/TD]
[TD="width: 124"]Sum of Actual Cases[/TD]
[TD="width: 95"]Purchase Number[/TD]
[/TR]
[TR]
[TD="width: 132"]Feb 10, 20014
[/TD]
[TD="width: 108"]Product 1[/TD]
[TD="width: 96"]Outlet 1[/TD]
[TD="width: 124"][/TD]
[TD="width: 95"][/TD]
[/TR]
[TR]
[TD="width: 132, bgcolor: transparent"]Feb 10, 20014
[/TD]
[TD="width: 108, bgcolor: transparent"]Product 2[/TD]
[TD="width: 96, bgcolor: transparent"]Outlet 1[/TD]
[TD="width: 124, bgcolor: transparent"][/TD]
[TD="width: 95, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 132"]Feb 10, 20014
[/TD]
[TD="width: 108"]Product 1[/TD]
[TD="width: 96"]Outlet 2[/TD]
[TD="width: 124"][/TD]
[TD="width: 95"][/TD]
[/TR]
[TR]
[TD="width: 132, bgcolor: transparent"]Feb 11, 20014
[/TD]
[TD="width: 108, bgcolor: transparent"]Product 3[/TD]
[TD="width: 96, bgcolor: transparent"]Outlet 1[/TD]
[TD="width: 124, bgcolor: transparent"][/TD]
[TD="width: 95, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 132"]Feb 17, 20014[/TD]
[TD="width: 108"]Product 2[/TD]
[TD="width: 96"]Outlet 1[/TD]
[TD="width: 124"][/TD]
[TD="width: 95"][/TD]
[/TR]
[TR]
[TD="width: 132, bgcolor: transparent"]Feb 17, 20014
[/TD]
[TD="width: 108, bgcolor: transparent"]Product 2[/TD]
[TD="width: 96, bgcolor: transparent"]Outlet 2[/TD]
[TD="width: 124, bgcolor: transparent"][/TD]
[TD="width: 95, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 132"]Feb 19, 20014
[/TD]
[TD="width: 108"]Product 2[/TD]
[TD="width: 96"]Outlet 1[/TD]
[TD="width: 124"][/TD]
[TD="width: 95"][/TD]
[/TR]
</tbody>[/TABLE]
I’m having trouble with the ‘Purchase number’ calculated field . It is the chronological number of times an outlet has purchased a particular product.
I tried adding
:=CALCULATE (
DISTINCTCOUNT('Sales Table'[Invoice Date]),
FILTER (
ALL ( 'Date Table'),
'Date Table'[Date] <= MAX ('Date Table'[Date])
)
)
But the resulting output is always 1 – I think the ‘Sales Table’[Invoice date] is limiting the date range. When I replace ‘Sales Table’[Invoice date] with 'Date Table'[Date] field it works fine but it populates a table with all the dates – including those dates without sales.
Any help here would be fantastic
Dan
I have a DAX question I’m having trouble finding an answer for in this forum. I’ve found some good answers on cumulative totals but nothing that will work in the context I need it in.
I have a sales table linked to three dimension tables: date table (Sale Table Key: Invoice Date), customer table (Sale Table Key: Outlet Number) and product table (Sale Table Key: Product number).
I need a table with two calculated fields ('Sum of Actual Cases' &'Purchase Number') as follows:
[TABLE="width: 415"]
<tbody>[TR]
[TD="width: 132"]Invoice Date
[/TD]
[TD="width: 108"]Product Number[/TD]
[TD="width: 96"]Outlet Number[/TD]
[TD="width: 124"]Sum of Actual Cases[/TD]
[TD="width: 95"]Purchase Number[/TD]
[/TR]
[TR]
[TD="width: 132"]Feb 10, 20014
[/TD]
[TD="width: 108"]Product 1[/TD]
[TD="width: 96"]Outlet 1[/TD]
[TD="width: 124"]
5
[TD="width: 95"]
1
[/TR]
[TR]
[TD="width: 132, bgcolor: transparent"]Feb 10, 20014
[/TD]
[TD="width: 108, bgcolor: transparent"]Product 2[/TD]
[TD="width: 96, bgcolor: transparent"]Outlet 1[/TD]
[TD="width: 124, bgcolor: transparent"]
3
[TD="width: 95, bgcolor: transparent"]
1
[/TR]
[TR]
[TD="width: 132"]Feb 10, 20014
[/TD]
[TD="width: 108"]Product 1[/TD]
[TD="width: 96"]Outlet 2[/TD]
[TD="width: 124"]
4
[TD="width: 95"]
1
[/TR]
[TR]
[TD="width: 132, bgcolor: transparent"]Feb 11, 20014
[/TD]
[TD="width: 108, bgcolor: transparent"]Product 3[/TD]
[TD="width: 96, bgcolor: transparent"]Outlet 1[/TD]
[TD="width: 124, bgcolor: transparent"]
3
[TD="width: 95, bgcolor: transparent"]
1
[/TR]
[TR]
[TD="width: 132"]Feb 17, 20014[/TD]
[TD="width: 108"]Product 2[/TD]
[TD="width: 96"]Outlet 1[/TD]
[TD="width: 124"]
2
[TD="width: 95"]
2
[/TR]
[TR]
[TD="width: 132, bgcolor: transparent"]Feb 17, 20014
[/TD]
[TD="width: 108, bgcolor: transparent"]Product 2[/TD]
[TD="width: 96, bgcolor: transparent"]Outlet 2[/TD]
[TD="width: 124, bgcolor: transparent"]
3
[TD="width: 95, bgcolor: transparent"]
1
[/TR]
[TR]
[TD="width: 132"]Feb 19, 20014
[/TD]
[TD="width: 108"]Product 2[/TD]
[TD="width: 96"]Outlet 1[/TD]
[TD="width: 124"]
3
[TD="width: 95"]
3
[/TR]
</tbody>[/TABLE]
I’m having trouble with the ‘Purchase number’ calculated field . It is the chronological number of times an outlet has purchased a particular product.
I tried adding
:=CALCULATE (
DISTINCTCOUNT('Sales Table'[Invoice Date]),
FILTER (
ALL ( 'Date Table'),
'Date Table'[Date] <= MAX ('Date Table'[Date])
)
)
But the resulting output is always 1 – I think the ‘Sales Table’[Invoice date] is limiting the date range. When I replace ‘Sales Table’[Invoice date] with 'Date Table'[Date] field it works fine but it populates a table with all the dates – including those dates without sales.
Any help here would be fantastic
Dan