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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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