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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Syndicate_Admin
Administrator
Administrator

Calculation annual change (values in columns)

Hello! I am stuck in my dashboard where I need to make a simple subtraction of some values (Difference in € compared to the previous year), but since I have the layout of the table in columns, I have no way to create a new column with that annual variation (2023-2022):

jonasoya_0-1696585150892.png

The table has the following format:

jonasoya_2-1696585480677.png

(The data for the year 2023 are below, and what I am interested in including in the formula is the annual variation with respect to " Cod_Taric")

Greetings and thank you in advance!

Jonah O.

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

Hi  @Syndicate_Admin ,

 

Because this formula is conformed in my scenario, your PBIX doesn't have this table name, you need to replace the name of each table in the formula with the name of the table in your own PBIX

For example, in your picture: table name: 2022-1

Measure =
var _today=TODAY()
var _2022=
SUMX(
    FILTER(ALLSELECTED('2022-1'),
    '2022-1'[flujo]=MAX('2022-1'[flujo])&&'2022-1'[cod_taric]=MAX('2022-1'[cod_taric])&&
    '2022-1'[ano]=YEAR(_today)-1),[euros])
var _2023=
SUMX(
    FILTER(ALLSELECTED('2022-1'),
    '2022-1'[flujo]=MAX('2022-1'[flujo])&&'2022-1'[cod_taric]=MAX('2022-1'[cod_taric])&&
    '2022-1'[ano]=YEAR(_today)),[euros])    
return
_2023 - _2022

 

Best Regards,

Liu Yang

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

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Syndicate_Admin ,

 

Because this formula is conformed in my scenario, your PBIX doesn't have this table name, you need to replace the name of each table in the formula with the name of the table in your own PBIX

For example, in your picture: table name: 2022-1

Measure =
var _today=TODAY()
var _2022=
SUMX(
    FILTER(ALLSELECTED('2022-1'),
    '2022-1'[flujo]=MAX('2022-1'[flujo])&&'2022-1'[cod_taric]=MAX('2022-1'[cod_taric])&&
    '2022-1'[ano]=YEAR(_today)-1),[euros])
var _2023=
SUMX(
    FILTER(ALLSELECTED('2022-1'),
    '2022-1'[flujo]=MAX('2022-1'[flujo])&&'2022-1'[cod_taric]=MAX('2022-1'[cod_taric])&&
    '2022-1'[ano]=YEAR(_today)),[euros])    
return
_2023 - _2022

 

Best Regards,

Liu Yang

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

Syndicate_Admin
Administrator
Administrator

Thanks Liu!
When inserting the DAX, I get this error - Cannot find table ́Table ́ -

jonasoya_0-1696927252419.png

Any suggestions? Thank you very much in advance!

Best regards

v-yangliu-msft
Community Support
Community Support

Hi  @Syndicate_Admin ,

 

You can try the following dax:

Measure =
var _today=TODAY()
var _2022=
SUMX(
    FILTER(ALLSELECTED('Table'),
    'Table'[flujo]=MAX('Table'[flujo])&&'Table'[cod_taric]=MAX('Table'[cod_taric])&&
    'Table'[ano]=YEAR(_today)-1),[euros])
var _2023=
SUMX(
    FILTER(ALLSELECTED('Table'),
    'Table'[flujo]=MAX('Table'[flujo])&&'Table'[cod_taric]=MAX('Table'[cod_taric])&&
    'Table'[ano]=YEAR(_today)),[euros])    
return
_2023 - _2022

 

 

Best Regards,

Liu Yang

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

littlemojopuppy
Community Champion
Community Champion

Hi @Syndicate_Admin 

Change your data model.  Unpivot year into a new column in the fact table.  By the way...create a date table too and give year an actual date value (January 1, December 31...doesn't matter).  Then this becomes pretty easy with some time intelligence functions.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.