Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
HereWeGoAgain
Contributor III
Contributor III

IF condition

Good Day

 

Please assist in changing the calculation in order for it to show only the 3 months before the current month:

=if(monthname(LoadDate)>=AddMonths(Max(total Monthname(LoadDate)),-2),Monthname(LoadDate))

 

 

currently is shows: Jun'22/May'22/Apr'22

I want it to show: May'22/Apr'22/Mar'22

 

Thanks in Advance 

Kind Regards

Labels (2)
5 Replies
vinieme12
Champion III
Champion III

=if(LoadDate>=monthstart(LoadDate,-3) and LoadDate<=monthend(LoadDate,-1), Monthname(LoadDate))

 

OR

=Aggr(Only({<LoadDate={">=monthstart(LoadDate,-3)<=monthend(LoadDate,-1)"}>}LoadDate),LoadDate)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
HereWeGoAgain
Contributor III
Contributor III
Author

@vinieme12 Hi,

 

This does not seem to be working.

what i currently have: (i want it to show only from May'22 and back)

HereWeGoAgain_0-1654586069435.png

 

With your calculation:

HereWeGoAgain_1-1654586111393.png

 

 

vinieme12
Champion III
Champion III

It wasn't clear if you needed this for a dimension or a measure,

 

measure syntax

=Sum({<LoadDate={">=monthstart(LoadDate,-3)<=monthend(LoadDate,-1)"}>}  Sales)

OR

=Sum({<LoadDate={">=$(=Date(monthstart(LoadDate,-3),'DD-MM-YYYY'))<=$(=Date(monthend(LoadDate,-1),'DD-MM-YYYY'))"}>}  Sales)

 

replace DD-MM-YYYY with the date format for LoadDate

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
HereWeGoAgain
Contributor III
Contributor III
Author

Apologies, it's in the Dimensions field: "Bars"

 

HereWeGoAgain_0-1654588252451.png

 

vinieme12
Champion III
Champion III

You can restrict calculations in measure too, the output will be same

try  below

=Sum({<LoadDate={">=$(=Date(monthstart(LoadDate,-3),'DD-MM-YYYY'))<=$(=Date(monthend(LoadDate,-1),'DD-MM-YYYY'))"}>}  Sales)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.