Forum Discussion
MarieKatherineJ
3 years agoFrequent Visitor
Calculate Sum Filter with a Circular Dependancy error
Hi community ! I am new with DAX and I would like to create 3 calculated columns with multiple criterias. First Column : Sales of this week The first criteria is the fiscalweek : the actual wee...
andhiii079845
Solution Sage
3 years agoYou can improve this:
SalesThisWeek = calculate(
sum('public VentesProduitsStoreParJour'[QTYVENDU]),
--first criteria : fiscalweek must equal this week
FILTER('public FiscalDates',
('public FiscalDates'[TRANSDATE].[Date]=TODAY() && 'public VentesProduitsStoreParJour'[FISCALWEEK]='public FiscalDates'[FISCALWEEK])),
--second criteria : : fiscalyear must equal this year
--second criteria : : fiscalyear must equal this year
FILTER('public FiscalDates',
('public FiscalDates'[TRANSDATE].[Date]=TODAY() && 'public VentesProduitsStoreParJour'[FISCALYEAR]='public FiscalDates'[FISCALYEAR]))
)
You make it i think to complicated. I think you are able to access directly the right fiscalweek via "relatedtable"
Like this:
Salesthisweek =
VAR _date= TODAY()
VAR _fiscal = CALCULATE(max(Dim[Fiscalweek]),FILTER(Dim,Dim[Date]=_date))
RETURN CALCULATE(sum('Table'[Sale]),FILTER(RELATEDTABLE(Dim),Dim[Fiscalweek]=_fiscal))
Try for the other measure
Saleslastweek =
VAR _date= TODAY()-7
VAR _fiscal = CALCULATE(max(Dim[Fiscalweek]),FILTER(Dim,Dim[Date]=_date))
RETURN CALCULATE(sum('Table'[Sale]),FILTER(RELATEDTABLE(Dim),Dim[Fiscalweek]=_fiscal))
Nevertheless, can you please share some data examples for the both tables?
- MarieKatherineJ3 years agoFrequent Visitor
Hello !
Thank you for your reply and sorry for taking so long.
I tried reproducing your function but when I type "Var_ " it doesn't exist. It proposes to me : "Var.P , Var.S, Varx.P or Varx.S.
Is there something I did not understand ?
Thank you !- andhiii0798453 years ago
Solution Sage
It called VAR "name" like:
my measure =
VAR _test = 1VAR result = 2
Return result
you write VAR_