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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ossama_ibrahim8
Regular Visitor

subtract sales units from previous day

i had daily sales sent tom me in excel but mtd 

so i need to sustract day 2 from day 1 to get real day 2 

i need dax formula to subtact with date 

can you help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ossama_ibrahim8 ,

 

Is this a matrix or a table of data sources?
If it is a data source, it is best to unpivot the date in Power Query and turn the date into a separate column.

Select the Item Code and Item name, click 'Unpivot Other Columns'.

vstephenmsft_0-1662975642772.png

You could get a column of dates and a column of values.

vstephenmsft_1-1662975652617.png

Now you could create the following measure to get the value from previous day.

Previous Value = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),[Item Code]=MAX('Table'[Item Code])&&[Attribute]=MAX('Table'[Attribute])-1))

vstephenmsft_2-1662975874965.png

 

 

 

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.

 

View solution in original post

4 REPLIES 4
ossama_ibrahim8
Regular Visitor

n=i need to subtract 3-7-2022 value with items sales from 2-7-2022 value and every day 

ossama_ibrahim8
Regular Visitor

sub.PNG

Anonymous
Not applicable

Hi @ossama_ibrahim8 ,

 

Is this a matrix or a table of data sources?
If it is a data source, it is best to unpivot the date in Power Query and turn the date into a separate column.

Select the Item Code and Item name, click 'Unpivot Other Columns'.

vstephenmsft_0-1662975642772.png

You could get a column of dates and a column of values.

vstephenmsft_1-1662975652617.png

Now you could create the following measure to get the value from previous day.

Previous Value = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),[Item Code]=MAX('Table'[Item Code])&&[Attribute]=MAX('Table'[Attribute])-1))

vstephenmsft_2-1662975874965.png

 

 

 

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.

 

Anonymous
Not applicable

Hi @ossama_ibrahim8 ,

 

It's the Power Query Forum. M language is used in it. While dax is used in Power BI Desktop.

And here's the blog teaches you how to get the value from previous row:

Value from previous row – Power Query, M language – Trainings, consultancy, tutorials (exceltown.com...

 

 

 

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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.