Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I am trying to create a measure which requires a min(dateadd) filter however it is not possible in Powerbi So i was wondering if there is another way to achieve this:
My current Measure:
Aged Wip 1 month=
return CALCULATE([WIP Close],FILTER('Age Date','Age Date'[Age Date] <= Max('Tran Date'[Tran Date])
))
MY report has a period filter which is the (Tran Date). The measure above basically makes sure the Age Date is less than or equal to the Max Tran date (in the filter report pane).
However I need to make a measure which includes a filter to this "Aged Wip 1 Month" to say that the Age Date has to be >= TranDate - 1 month. This will give me all WIP Closed with an age date within 1 month of the max tran date.
Is this possible in powerbi? The business requires this in a measure form.
Solved! Go to Solution.
Hi @Anonymous
For example, [tran date] is added into Report level filter, max tran date is 2020/3/15
if i use function below, it recorgnize that 2020/2/1~2020/3/15 is the period within one month of the max tran date.
max tran date = MAX('tran datedate'[tran date])
within 1 month = IF(MAX('Age date'[age date])<=[max tran date]&&DATEDIFF(MAX([age date]),[max tran date],MONTH)<=1,1,0)
Measure = CALCULATE(COUNT('Age date'[age date]),FILTER('Age date',[within 1 month]=1))
If your expected result is not like this, please let me know.
Hi @Anonymous
For example, [tran date] is added into Report level filter, max tran date is 2020/3/15
if i use function below, it recorgnize that 2020/2/1~2020/3/15 is the period within one month of the max tran date.
max tran date = MAX('tran datedate'[tran date])
within 1 month = IF(MAX('Age date'[age date])<=[max tran date]&&DATEDIFF(MAX([age date]),[max tran date],MONTH)<=1,1,0)
Measure = CALCULATE(COUNT('Age date'[age date]),FILTER('Age date',[within 1 month]=1))
If your expected result is not like this, please let me know.
Thanks this worked perfectly, it takes 3 seconds to load but i guess that will have to do, i am not sure why datediff did not work previously.
Question: Actually i think it did not work before because my Max(Date) Query was in the measure and not build outside the measure as its own standalone measure. Does anybody Know why you need to have the Max(Date) Measure outside of the Measure. IE you cant have Var MaxDate = Max(Date) or just Max(Date) in the measure itself you have to create a seperate measure?
For others looking at this post i had t ochange the within 1 month to :
var within1month = IF([maxAge]<=[maxtrandate],if(DATEDIFF([maxAge],[maxtrandate],MONTH)=1,1,BLANK()),BLANK())1 month wip age =
var within1month = IF([maxAge]<=[maxtran],if(DATEDIFF([maxAge],[maxtran],MONTH)=1,1,BLANK()),BLANK())
return CALCULATE([WIP Close], FILTER('Age Date','Age Date'[Age Date] <= Max('Tran Date'[Tran Date]) && if(DATEDIFF([maxAge],[maxtran],MONTH)=1,1,BLANK()) = 1))
@Anonymous , I did not check the logic
But you have move max out if you need a max of slicer or date
Aged Wip 1 month=
var _max =Maxx('Tran Date','Tran Date'[Tran Date])
return
return CALCULATE([WIP Close],FILTER('Age Date','Age Date'[Age Date] <= _max
))
I actually do not have problems with the Max inside of the calculate. IT is filtering down as expected.
So far i have :
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.