Forum Discussion
Calculate date filter
Hello,
I ve been trying to improve my calculation with additional date filter, but it doesnt make any diff. It behaves like it calculates the result for all dates
Everything is calculates in one table. measure reacts correctly to date slicer or filter visual modification, but only not for dax...
Aby idea what can be wrong?
Anonymous
Please tryYield Mech. assemblyprevmonth = VAR CurrentYearMonth = MAX ( 'Date'[Year Month Number] ) VAR MechAssembly = CALCULATETABLE ( TJob, TJob[SekundærNavn] = "Mech. assembly", 'Date'[Year Month Number] = CurrentYearMonth - 1, ALL ( 'Date' ) ) RETURN ROUND ( DIVIDE ( SUMX ( MechAssembly, TJob[FirstPassQty] ), SUMX ( MechAssembly, TJob[Antal] ) ), 4 )
17 Replies
- tamerj1Community Champion
Hi Anonymous
bring CALCULATE at line number 2 instead of 5
- AnonymousNot applicable
Could you elaborate more? You mean putting sumx as VAR?
Yield Mech. assembly =VAR nom =CALCULATE( SUMX(TJob, TJob[Antal]), TJob[SekundærNavn] = "Mech. assembly" , PREVIOUSMONTH(TJob[Dato]))VAR den =CALCULATE(SUMX(TJob, TJob[FirstPassQty]), TJob[SekundærNavn] = "Mech. assembly", PREVIOUSMONTH(TJob[Dato]))RETURNROUND(DIVIDE (den,nom),4)- tamerj1Community Champion
Anonymous
Please try
Yield Mech. assembly111 =
CALCULATE (
VAR MechAssembly =
FILTER ( TJob, TJob[SekundarNavn] = "Mech. assembly" )
RETURN
ROUND (
DIVIDE (
SUMX ( MechAssembly, TJob[Antal] ),
SUMX ( MechAssembly, TJob[FirstPassQty] )
),
4
),
PREVIOUSMONTH ( TJob[Dato] )
)
- AnonymousNot applicable
https://drive.google.com/file/d/1Ry9C5zrcUi59CV6j3GqAYjngYlr3wIYg/view?usp=sharing
Link for contoso model, same problem with different example
- AnonymousNot applicable
Hi Anonymous ,
Please try this measure:
(Try PARALLELPERIOD(TJob[Dato],-1,MONTH) instead of PREVIOUSMONTH(TJob[Dato]))
PrevMonth = CALCULATE(SUMX(Sales, Sales[Unit Cost]), PARALLELPERIOD('Date'[Date],-1,MONTH))Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Anonymous Calculated you presented isnt filtering any date. Its result of sumx with function all to each month? Could you try to download contoso file. Maybe my settings for file are disrupting the calculation... I m running out of ideas
- AnonymousNot applicable
ref
Sample of my file aatached also
https://drive.google.com/file/d/1fPAhnB2t2XWQKODOxKsEXRwD-_44Cm6r/view?usp=sharing