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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
adni85
Frequent Visitor

Column DAX Formula to Calculate Last 6 months change based on each category

Hi, I want the DAX Column measure formula to calculate the last 6-month change based on the product category. if the last 6 months data isn't available it should be displayed as blank not 0 or error. This is a table example for the output of the problem I am having. TIA 

 

Product CategoryDateNormalRateChangeLastMonthChangeLast6Months
BikeFeb-22100  
BikeMar-2295-5 
BikeApr-2254.51-40.49 
BikeMay-2285.2230.71 
BikeJun-2299.8814.66 
BikeJul-221000.12 
BikeAug-2210000
BikeSep-2210005
BikeOct-22100045.49
BikeNov-22100014.78
BikeDec-2210000.12
BikeJan-2310000
BikeFeb-2397-3-3
BikeMar-23981-2
BikeApr-2395-3-5
ShoesAug-22100  
ShoesSep-221000 
ShoesOct-221000 
ShoesNov-2290-10 
ShoesDec-2280-10 
ShoesJan-2370-10 
ShoesFeb-2360-10-40
ShoesMar-2350-10-50
ShoesApr-2340-10-60
ClothesJun-2225  
ClothesJul-223510 
ClothesAug-224510 
ClothesSep-225510 
ClothesOct-226510 
ClothesNov-227510 
ClothesDec-22851060
ClothesJan-23951060
ClothesFeb-23100555
ClothesMar-2394-639
ClothesApr-2395130
ClothesMay-2391-416
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @adni85 

 try like:

Column = 
VAR _rate =
MAXX(
    FILTER(
       data,
       data[Product Category]=EARLIER(data[Product Category])
           &&data[Date]=EDATE(EARLIER([Date]), -6)
    ),
   data[NormalRate]
)
VAR Result =
IF(
    ISBLANK(_rate), 
    BLANK(), 
    [NormalRate] - _rate
)
RETURN Result

 

it worked like:FreemanZ_1-1681467804599.png

 

View solution in original post

2 REPLIES 2
adni85
Frequent Visitor

Thanks, @FreemanZ !

 

It worked perfectly.

 

FreemanZ
Super User
Super User

hi @adni85 

 try like:

Column = 
VAR _rate =
MAXX(
    FILTER(
       data,
       data[Product Category]=EARLIER(data[Product Category])
           &&data[Date]=EDATE(EARLIER([Date]), -6)
    ),
   data[NormalRate]
)
VAR Result =
IF(
    ISBLANK(_rate), 
    BLANK(), 
    [NormalRate] - _rate
)
RETURN Result

 

it worked like:FreemanZ_1-1681467804599.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.