Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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?
Solved! Go to Solution.
@Anonymous
Please try
Yield 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
)
ref
Sample of my file aatached also
https://drive.google.com/file/d/1fPAhnB2t2XWQKODOxKsEXRwD-_44Cm6r/view?usp=sharing
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.
@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
https://drive.google.com/file/d/1Ry9C5zrcUi59CV6j3GqAYjngYlr3wIYg/view?usp=sharing
Link for contoso model, same problem with different example
Hi @Anonymous
bring CALCULATE at line number 2 instead of 5
Could you elaborate more? You mean putting sumx as VAR?
@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] )
)
Idk know why but the measure keeps displaying blank after previous month function. So as few others i had try for example
Date column is correctly formatted as date, rest as whole number.
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?
@Anonymous
Please try
Yield 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
)
You re a God!
The magic question what is the purpose of previousmonth function if its not working... or why is it not working
@Anonymous
It should work but I usually don't like to use time intellagence functions. You may try
Yield 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
)
@Anonymous
Forgot to mention that it returns blank if the date table is not filtered i.e. at the grand total level.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
9 |