cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

New Member

## How can i creat a table that summarize two dates by diferents periods

I have this table:

I need to creat a new table like this:

Can help me? Thks

1 ACCEPTED SOLUTION
Community Support

Here's the solution.

Sample data:

1.Create a table for two value types by entering data:

2.Create threes measures for different periods.

``````1 months =
var _start=EOMONTH(MAX('Table'[Data]),-1)
var _end=EOMONTH(MAX('Table'[Data]),0)
var _aptos=CALCULATE(SUM('Table'[Valor Aptos]),FILTER('Table',[Data]>_start&&[Data]<=_end))
var _casas=CALCULATE(SUM('Table'[Valor Casas]),FILTER('Table',[Data]>_start&&[Data]<=_end))
return SWITCH(MAX('Table (2)'[Type]),"Valor Aptos",_aptos,"Valor Casas",_casas)``````
``````6 months =
var _start=EOMONTH(MAX('Table'[Data]),-6)
var _end=EOMONTH(MAX('Table'[Data]),0)
var _aptos=CALCULATE(SUM('Table'[Valor Aptos]),FILTER('Table',[Data]>_start&&[Data]<=_end))
var _casas=CALCULATE(SUM('Table'[Valor Casas]),FILTER('Table',[Data]>_start&&[Data]<=_end))
return SWITCH(MAX('Table (2)'[Type]),"Valor Aptos",_aptos,"Valor Casas",_casas)``````
``````12 months =
var _start=EOMONTH(MAX('Table'[Data]),-12)
var _end=EOMONTH(MAX('Table'[Data]),0)
var _aptos=CALCULATE(SUM('Table'[Valor Aptos]),FILTER('Table',[Data]>_start&&[Data]<=_end))
var _casas=CALCULATE(SUM('Table'[Valor Casas]),FILTER('Table',[Data]>_start&&[Data]<=_end))
return SWITCH(MAX('Table (2)'[Type]),"Valor Aptos",_aptos,"Valor Casas",_casas)``````

Best Regards,

Stephen Tao

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

3 REPLIES 3
Community Support

Here's the solution.

Sample data:

1.Create a table for two value types by entering data:

2.Create threes measures for different periods.

``````1 months =
var _start=EOMONTH(MAX('Table'[Data]),-1)
var _end=EOMONTH(MAX('Table'[Data]),0)
var _aptos=CALCULATE(SUM('Table'[Valor Aptos]),FILTER('Table',[Data]>_start&&[Data]<=_end))
var _casas=CALCULATE(SUM('Table'[Valor Casas]),FILTER('Table',[Data]>_start&&[Data]<=_end))
return SWITCH(MAX('Table (2)'[Type]),"Valor Aptos",_aptos,"Valor Casas",_casas)``````
``````6 months =
var _start=EOMONTH(MAX('Table'[Data]),-6)
var _end=EOMONTH(MAX('Table'[Data]),0)
var _aptos=CALCULATE(SUM('Table'[Valor Aptos]),FILTER('Table',[Data]>_start&&[Data]<=_end))
var _casas=CALCULATE(SUM('Table'[Valor Casas]),FILTER('Table',[Data]>_start&&[Data]<=_end))
return SWITCH(MAX('Table (2)'[Type]),"Valor Aptos",_aptos,"Valor Casas",_casas)``````
``````12 months =
var _start=EOMONTH(MAX('Table'[Data]),-12)
var _end=EOMONTH(MAX('Table'[Data]),0)
var _aptos=CALCULATE(SUM('Table'[Valor Aptos]),FILTER('Table',[Data]>_start&&[Data]<=_end))
var _casas=CALCULATE(SUM('Table'[Valor Casas]),FILTER('Table',[Data]>_start&&[Data]<=_end))
return SWITCH(MAX('Table (2)'[Type]),"Valor Aptos",_aptos,"Valor Casas",_casas)``````

Best Regards,

Stephen Tao

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

Super User

Hello @DanielPontes , to calculate one month, 6 months and 12 months we need a date from which it has to calculate like that once that is available then using 'ADDCOLUMNS' DAX you can achieve this I believe.

So please decide a date from which these filters need to be calculated and then create your new table.

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

New Member

Hello @Kishore_KVN

Your idea works if i had one date, bat I have "Valor Casa" anda Valor Aptos". I try use ADDCOLUMNS and CALCULATE, but it's not possible add more than one line, and I need one for each time that I need comparate ("1month", "2month", "3 month"). Like this:

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors