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
Anonymous
Not applicable

% issue without referencing time

Hello Exports,
As you see in photot attached, I am not referencing time and used time intelligence function and it give me a number, and npte in my data in data I have year only, 
How I can deal with that? anf if its no give me zero, it can make % between  2015 % 2020 whwn I am not referncing time.

 

 

Growthg.png

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

Hi @Anonymous 

 

Maybe you can try this expression to do that:

yoy % =
VAR _amountly =
    CALCULATE ( [value], DATEADD ( 'Table'[Date], -1, YEAR ) )
VAR _yoy = [value] - _amountly
VAR _result =
    DIVIDE ( _yoy, ABS ( _amountly ) )
VAR _minyear =
    CALCULATE (
        [value],
        FILTER (
            ALLSELECTED ( 'Table'[Date] ),
            [Date] >= DATE ( YEAR ( MIN ( 'Table'[Date] ) ), 1, 1 )
                && [Date] <= DATE ( YEAR ( MIN ( 'Table'[Date] ) ), 12, 31 )
        )
    )
VAR _maxyear =
    CALCULATE (
        [value],
        FILTER (
            ALLSELECTED ( 'Table'[Date] ),
            [Date] >= DATE ( YEAR ( MAX ( 'Table'[Date] ) ), 1, 1 )
                && [Date] <= DATE ( YEAR ( MAX ( 'Table'[Date] ) ), 12, 31 )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Table'[Date].[Year] ),
        _result + 0,
        DIVIDE ( _maxyear - _minyear, ABS ( _minyear ) ) + 0
    )

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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-chenwuz-msft
Community Support
Community Support

Hi @Anonymous 

 

Maybe you can try this expression to do that:

yoy % =
VAR _amountly =
    CALCULATE ( [value], DATEADD ( 'Table'[Date], -1, YEAR ) )
VAR _yoy = [value] - _amountly
VAR _result =
    DIVIDE ( _yoy, ABS ( _amountly ) )
VAR _minyear =
    CALCULATE (
        [value],
        FILTER (
            ALLSELECTED ( 'Table'[Date] ),
            [Date] >= DATE ( YEAR ( MIN ( 'Table'[Date] ) ), 1, 1 )
                && [Date] <= DATE ( YEAR ( MIN ( 'Table'[Date] ) ), 12, 31 )
        )
    )
VAR _maxyear =
    CALCULATE (
        [value],
        FILTER (
            ALLSELECTED ( 'Table'[Date] ),
            [Date] >= DATE ( YEAR ( MAX ( 'Table'[Date] ) ), 1, 1 )
                && [Date] <= DATE ( YEAR ( MAX ( 'Table'[Date] ) ), 12, 31 )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Table'[Date].[Year] ),
        _result + 0,
        DIVIDE ( _maxyear - _minyear, ABS ( _minyear ) ) + 0
    )

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

amitchandak
Super User
Super User

@Anonymous , based on what I got. Force the range again

 

example

 

0 between range
Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))

 

Anonymous
Not applicable

Hello @amitchandak , but in your code where is the year over year percentage?

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.