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
bolabuga
Helper V
Helper V

[ Comparing clients across years ]

Hello everyone,

 

I would like help with the calculation described on the screenshot:

 

sameclient.PNG

 

 

 

theres a sample table in excel here: https://drive.google.com/open?id=0B8Aq8DhGApJqUXJLWDJqekxvaWs

 

Thks in advance

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @bolabuga,

 

Based on currect sample data, suppose that the data type of column [MONTHYEAR] is set to text. 

 

Then, we should add some calculated columns into this table:

Year = RIGHT(Revenue[MonthYear],2)
Mon = LEFT(Revenue[MonthYear],3)

Clinet exist in another year =
IF (
    Revenue[Year] = 16,
    LOOKUPVALUE (
        Revenue[Clients],
        Revenue[Year], Revenue[Year] + 1,
        Revenue[Mon], Revenue[Mon],
        Revenue[Clients], Revenue[Clients]
    ),
    LOOKUPVALUE (
        Revenue[Clients],
        Revenue[Year], Revenue[Year] - 1,
        Revenue[Mon], Revenue[Mon],
        Revenue[Clients], Revenue[Clients]
    )
)

REVENUE2 =
IF (
    Revenue[Clinet exist in another year] <> BLANK (),
    CALCULATE (
        SUM ( Revenue[REVENUE] ),
        ALLEXCEPT ( Revenue, Revenue[Clients], Revenue[MonthYear] )
    ),
    BLANK ()
)

LY REVENUE =
LOOKUPVALUE (
    Revenue[REVENUE2],
    Revenue[Clients], Revenue[Clients],
    Revenue[Year], Revenue[Year] - 1,
    Revenue[Mon], Revenue[Mon]
)

 

The data table will be like:

1.PNG 

 

Based on my understanding, you only want to display revenue for 2017 in visual, right? I am not sure what visualization you want to use, in my test, I added a table visual to show data.

 

Use below formula to create a table which only contains data for 2017.

Table =
CALCULATETABLE ( Revenue, Revenue[Year] = 17 )

2.PNG

 

Best regards,
Yuliana Gu

 

 

Community Support Team _ Yuliana Gu
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
v-yulgu-msft
Employee
Employee

Hi @bolabuga,

 

Based on currect sample data, suppose that the data type of column [MONTHYEAR] is set to text. 

 

Then, we should add some calculated columns into this table:

Year = RIGHT(Revenue[MonthYear],2)
Mon = LEFT(Revenue[MonthYear],3)

Clinet exist in another year =
IF (
    Revenue[Year] = 16,
    LOOKUPVALUE (
        Revenue[Clients],
        Revenue[Year], Revenue[Year] + 1,
        Revenue[Mon], Revenue[Mon],
        Revenue[Clients], Revenue[Clients]
    ),
    LOOKUPVALUE (
        Revenue[Clients],
        Revenue[Year], Revenue[Year] - 1,
        Revenue[Mon], Revenue[Mon],
        Revenue[Clients], Revenue[Clients]
    )
)

REVENUE2 =
IF (
    Revenue[Clinet exist in another year] <> BLANK (),
    CALCULATE (
        SUM ( Revenue[REVENUE] ),
        ALLEXCEPT ( Revenue, Revenue[Clients], Revenue[MonthYear] )
    ),
    BLANK ()
)

LY REVENUE =
LOOKUPVALUE (
    Revenue[REVENUE2],
    Revenue[Clients], Revenue[Clients],
    Revenue[Year], Revenue[Year] - 1,
    Revenue[Mon], Revenue[Mon]
)

 

The data table will be like:

1.PNG 

 

Based on my understanding, you only want to display revenue for 2017 in visual, right? I am not sure what visualization you want to use, in my test, I added a table visual to show data.

 

Use below formula to create a table which only contains data for 2017.

Table =
CALCULATETABLE ( Revenue, Revenue[Year] = 17 )

2.PNG

 

Best regards,
Yuliana Gu

 

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yulgu-msft

 

Really thanks, 

 

I can apply this solution and on the top of that it cleaned some doubts i had on using lookupvalue function. 

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.