Forum Discussion
Calculate date filter
- 3 years ago
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 )
Could you reference measure to VAR version. Contoso model looks very good, refering to year month number is pretty nifty idea, but when i tried to copy results....
It still wont give me the previous month
Anonymous
Can you copy/paste this code so I can modify?
- Anonymous3 years agoNot applicable
And it returns blank. Well it doesnt matter right now. Thank you.
To bad dax guides for time intelligence are showing easy results, nothing real life databases. At least for me
- tamerj13 years agoCommunity Champion
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 ) - Anonymous3 years agoNot applicableYield Mech. assemblyprevmonth =VAR MechAssembly =FILTER ( TJob, TJob[SekundærNavn] = "Mech. assembly" )RETURNCALCULATE(ROUND(DIVIDE (SUMX ( MechAssembly, TJob[FirstPassQty] ),SUMX ( MechAssembly, TJob[Antal] ) ),4),ALL('Date'),'Date'[Year Month Number] = MAX('Date'[Year Month Number]) -1)
- Anonymous3 years agoNot applicable
You re a God!
The magic question what is the purpose of previousmonth function if its not working... or why is it not working
- tamerj13 years agoCommunity Champion
Anonymous
It should work but I usually don't like to use time intellagence functions. You may tryYield Mech. assemblyprevmonth = VAR CurrentYearMonth = MAX ( 'Date'[Year Month Number] ) VAR MechAssembly = CALCULATETABLE ( TJob, TJob[SekundærNavn] = "Mech. assembly", PREVIOUSMONTH ( 'Date'[Date] ) ) RETURN ROUND ( DIVIDE ( SUMX ( MechAssembly, TJob[FirstPassQty] ), SUMX ( MechAssembly, TJob[Antal] ) ), 4 ) - tamerj13 years agoCommunity Champion
Anonymous
Forgot to mention that it returns blank if the date table is not filtered i.e. at the grand total level.