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

daily change

so i have the following data

 

Country/RegioncasosMesDíacasos por dia
Argentina1054abril1 
Argentina1133abril279
Argentina1265abril3132
Argentina1451abril4186
Argentina1451abril50
Argentina1554abril6103
Argentina1628abril774
Argentina1715abril887
Argentina1795abril980

 

i need to create the column "casos por dia" in power bi con dax, the column must be a daily grow, so the difference between a day and the day before, must work for many countrys , months and year, the date can be change to any format.

i need to do it in dax to publish in power bi, the data come from the cloud

 

 

1 ACCEPTED SOLUTION
bheepatel
Resolver IV
Resolver IV

Hi @Anonymous 

 

You will need to make sure that you have one column for Date. I create a sample data model with the following columns:

  • Country
  • Date
  • Amount

I then created two more columns called DateBefore (which is the previous day's date) and Change (which is the change from previous day). Please see the screenshots below for the DAX expression for those 2 new columns.

 

1.JPG

 

2.JPG

 

Hope this help!

 

If I have answered your questions please Accept this post as a solution!

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Such calculations should be performed in Power Query, not in DAX. Please use the right tool for the job. Thanks.

Best
D

@Anonymous I would beg to differ. There is no written law which says what tool should be used for what calculation. At the end of the day it comes down to personal preference 🙂

Anonymous
Not applicable

@bheepatel, I beg to differ. Calculated columns are never compressed optimally by the SSAS engine, therefore if you want to get the best of your model in terms of space and speed, you'd better use Power Query.

What's more, DAX has no concept of order whereas Power Query, the M language, does. Hence calculations like yours should be performed in PQ.

Best
D
Anonymous
Not applicable

And... of course, DAX is a Data eXpression Analysis language, not data mashup language. And what this is trying to do is re-shaping/enriching data.

Best
D
bheepatel
Resolver IV
Resolver IV

Hi @Anonymous 

 

You will need to make sure that you have one column for Date. I create a sample data model with the following columns:

  • Country
  • Date
  • Amount

I then created two more columns called DateBefore (which is the previous day's date) and Change (which is the change from previous day). Please see the screenshots below for the DAX expression for those 2 new columns.

 

1.JPG

 

2.JPG

 

Hope this help!

 

If I have answered your questions please Accept this post as a solution!

Anonymous
Not applicable

thanks for the answer, at the end i solve it by power query, duplicating the table then creating another column with the day before and the data of the day before then using the difference in another column , your solution is more elegant.

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.

Top Solution Authors