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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Dynamic measure or calculation to get new, old or drop based on previous year/quarter/month

Could you please help me to solve the below problem. It is getting tough for me to come to conclusion on choosing the path to solve below.

 

Requirement

The sales of a Material are categorized over a period-by-period comparison and the actual status is determined for the current period

The following categorization is required. This comparison can be between years or quarters or months

Problem Statement

This comparison should be dynamic between years, quarters and months and the above comparisons should be built dynamically on the fly

 

Material Code20202021Measure 
abc 30new 
xyz15 drop 
sss1516existing 

 

 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

Try this:

Measure = 
var _pre=Not(ISBLANK(SELECTEDVALUE('Table'[2020])))
var _current=Not(ISBLANK(SELECTEDVALUE('Table'[2021])))

var _if=IF(_pre=TRUE()&&_current=TRUE(),"existing",IF(_pre=TRUE()&&_current=FALSE(),"drop","new"))
return _if

Result:

vangzhengmsft_0-1641781619191.png

 

Custom time-related calculations:

Sales YOY :=
VAR ValueCurrentPeriod = [Sales Amount]
VAR ValuePreviousPeriod = [Sales PY]
VAR Result =
    IF (
        NOT ISBLANK ( ValueCurrentPeriod )
            && NOT ISBLANK ( ValuePreviousPeriod ),
        ValueCurrentPeriod - ValuePreviousPeriod
    )
RETURN
    Result
Sales MOM :=
VAR ValueCurrentPeriod = [Sales Amount]
VAR ValuePreviousPeriod = [Sales PM]
VAR Result =
    IF (
        NOT ISBLANK ( ValueCurrentPeriod )
            && NOT ISBLANK ( ValuePreviousPeriod ),
        ValueCurrentPeriod - ValuePreviousPeriod
    )
RETURN
    Result

 

refer:

https://www.daxpatterns.com/custom-time-related-calculations/

 

If the above doesn't work for you, please consider sharing more details about it and posting expected result so it is clear on what needs to be implemented?  And It would be great if there is a sample file without any sesentive information here.It makes it easier to give you a solution.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

Try this:

Measure = 
var _pre=Not(ISBLANK(SELECTEDVALUE('Table'[2020])))
var _current=Not(ISBLANK(SELECTEDVALUE('Table'[2021])))

var _if=IF(_pre=TRUE()&&_current=TRUE(),"existing",IF(_pre=TRUE()&&_current=FALSE(),"drop","new"))
return _if

Result:

vangzhengmsft_0-1641781619191.png

 

Custom time-related calculations:

Sales YOY :=
VAR ValueCurrentPeriod = [Sales Amount]
VAR ValuePreviousPeriod = [Sales PY]
VAR Result =
    IF (
        NOT ISBLANK ( ValueCurrentPeriod )
            && NOT ISBLANK ( ValuePreviousPeriod ),
        ValueCurrentPeriod - ValuePreviousPeriod
    )
RETURN
    Result
Sales MOM :=
VAR ValueCurrentPeriod = [Sales Amount]
VAR ValuePreviousPeriod = [Sales PM]
VAR Result =
    IF (
        NOT ISBLANK ( ValueCurrentPeriod )
            && NOT ISBLANK ( ValuePreviousPeriod ),
        ValueCurrentPeriod - ValuePreviousPeriod
    )
RETURN
    Result

 

refer:

https://www.daxpatterns.com/custom-time-related-calculations/

 

If the above doesn't work for you, please consider sharing more details about it and posting expected result so it is clear on what needs to be implemented?  And It would be great if there is a sample file without any sesentive information here.It makes it easier to give you a solution.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you so much @v-angzheng-msft  for your response.

Here the material name that I'm looking for is in same table. And the year must be picked up from the date.
I will try to implement in the same manner as you suggested.

Regards,

Munna

lbendlin
Super User
Super User

Familiarize yourself with the DAX functions EXCEPT() and INTERSECT() and use these in your measures.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors