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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
danisharoon
Helper I
Helper I

Not calculate MAT growth % if number of months are less then 12

I have some data on a month on month basis. I need to calculate the MAT growth for the selected Month year. Formula for which will be as follows:

MAT growth % = (MAT CY - MAT PY) / MAT PY

 

By CY we mean Current year, and by PY we mean Past year. For instance, if I select Jul'22, then MAT CY will compute a sum across Aug'21-Jul'22, and MAT PY will compute a sum across Aug'20-Jul'21.

 

MAT growth % should only be possible if values of exactly 12 monthly intervals are present in PY and CY.

 

Output from my DAX is as follows:

danisharoon_0-1668497867712.png

Greyed out cells are not desirable as they don't satisfy the 12 monthly interval requirement. Hence given the data, MAT growth % should be possible only for June and July'22.

 

DAX formulas are as follows

 

 

FACT TP = 
CALCULATE(
    SUM(fact_size_markets[Fact value]),
    DATESINPERIOD(
        dim_my[MY name],
        MAX(dim_my[MY name]),
        -1,
        YEAR
    )
)

 

 

 

 

 

FACT LP = 
CALCULATE(
    SUM(fact_size_markets[Fact value]),
    DATESINPERIOD(
        dim_my[MY name],
        LASTDATE(DATEADD(dim_my[MY name], -1,YEAR)),
        -1,
        YEAR
    )
)

 

 

 

Link to the pbix file is as follows: https://drive.google.com/file/d/1ifP1Knp_fh02i1vqbg-jeFYXqD-y2CPP/view?usp=sharing

Thanks

2 REPLIES 2
amitchandak
Super User
Super User

@danisharoon , Try like

 

FACT LP =
var _max1 = max(dim_my[MY name])
var _max = date(year(_max1) -1, month(_max1), Day(_max1))
return
CALCULATE(
SUM(fact_size_markets[Fact value]),
DATESINPERIOD(
dim_my[MY name],
_max,
-1,
YEAR
)
)

 

 

make sure dim_my is marked as date table and date in visual is used from dim_my

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

No improvement there. Its returning the same values.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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