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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply

Transitioning from Tableau - calculated Measure

I'm having alot of trouble with this one. In Tableau, I have a measure called "% Difference" - calculated as "ZN([%Pos Response]) - LOOKUP(ZN([%Pos Response]), -1)". This allows me, when I put Years in the columns area, to see the %Difference by year (there are thousands of rows, but only 3 years right now). The -1 telling it to compare with the previous year.

 

I cannot figure out how to transition this to PowerBi. 

%Pos Response is a calculated measure I've created in PowerBi that is calculated as follows (using two calculated columns): divide(sum([Count Positive]), sum(Data[PosNeg])).

 

Do people have ideas on how this can transition to PowerBI? There are a number of different values that I am needing this %Difference for, including some where I am hoping to drill down from "Question Group" to "Question"

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @daniel_krantz_4 

 

Maybe you can try this:

Here I create a measure:

% Difference =
VAR _currentYear =
    YEAR ( MAX ( 'Table'[Date] ) )
VAR _previousYear =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( ALLSELECTED ( 'TABLE' ), YEAR ( 'TABLE'[Date] ) < _currentYear )
    )
VAR CurrentYearValue =
    CALCULATE (
        [%Pos Response],
        FILTER ( ALLSELECTED ( 'Date' ), YEAR ( 'Table'[Date] ) = _currentYear )
    )
VAR PreviousYearValue =
    CALCULATE (
        [%Pos Response],
        FILTER ( ALLSELECTED ( 'Date' ), YEAR ( 'Table'[Date] ) = _previousYear )
    )
RETURN
    IF (
        NOT ISBLANK ( CurrentYearValue ),
        ( CurrentYearValue - PreviousYearValue ) / PreviousYearValue,
        BLANK ()
    )

 You can change the 'Table'[Date] into your own table's Date column.

 

Best Regards

Zhengdong Xu
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

2 REPLIES 2
Anonymous
Not applicable

Hi @daniel_krantz_4 

 

Maybe you can try this:

Here I create a measure:

% Difference =
VAR _currentYear =
    YEAR ( MAX ( 'Table'[Date] ) )
VAR _previousYear =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( ALLSELECTED ( 'TABLE' ), YEAR ( 'TABLE'[Date] ) < _currentYear )
    )
VAR CurrentYearValue =
    CALCULATE (
        [%Pos Response],
        FILTER ( ALLSELECTED ( 'Date' ), YEAR ( 'Table'[Date] ) = _currentYear )
    )
VAR PreviousYearValue =
    CALCULATE (
        [%Pos Response],
        FILTER ( ALLSELECTED ( 'Date' ), YEAR ( 'Table'[Date] ) = _previousYear )
    )
RETURN
    IF (
        NOT ISBLANK ( CurrentYearValue ),
        ( CurrentYearValue - PreviousYearValue ) / PreviousYearValue,
        BLANK ()
    )

 You can change the 'Table'[Date] into your own table's Date column.

 

Best Regards

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

Thank you! I made some small changes to fit my data and realized I didn't need the divide statement, but this works! Here was the final code:

 

%Difference =
VAR _currentYear = MAX('Data'[Year])
VAR _previousYear =CALCULATE(MAX('Data'[Year]),
FILTER(ALLEXCEPT('Data', 'Data'[QGroup], 'Data'[Question]),'Data'[Year] < _currentYear))

VAR CurrentYearValue =CALCULATE([%Pos Response],
FILTER(ALLEXCEPT('Data', 'Data'[QGroup], 'Data'[Question]),'Data'[Year] = _currentYear))
VAR PreviousYearValue =CALCULATE([%Pos Response],
FILTER(ALLEXCEPT('Data', 'Data'[QGroup], 'Data'[Question]),'Data'[Year] = _previousYear))
RETURN
IF(NOT ISBLANK(CurrentYearValue),CurrentYearValue - PreviousYearValue, BLANK())

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.