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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
cccarv82
Frequent Visitor

How can i subtract a value by date ? [Solved]

I have a table that looks like this:

cccarv82_0-1651717227802.png

 

 

what i need to do to add a column that subtract a certain amount (this certain amount will be a measure) considering the date ?

So i have something like this:

 

cccarv82_2-1651717529776.png

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @cccarv82 
Here is the sample file with the solution https://we.tl/t-eHYz5Ypz3F

I hope this is what you're looking for

Actual Value = 
VAR Current_Value = Table_1[value]
VAR Current_Date = Table_1[date_day_by_day]
VAR CurrentItem_Table = CALCULATETABLE ( Table_1, ALLEXCEPT ( Table_1, Table_1[Name] ) )
VAR First_Date = MINX ( CurrentItem_Table, Table_1[date_day_by_day] )
VAR Last_Date = MAXX ( CurrentItem_Table, Table_1[date_day_by_day] )
VAR NumberOfDays = DATEDIFF ( First_Date, Current_Date, DAY )
VAR TotalNumberOfDays = DATEDIFF ( First_Date, Last_Date, DAY )
VAR DailyValue = DIVIDE ( Current_Value, TotalNumberOfDays )
RETURN
    Current_Value - DailyValue * NumberOfDays

1.png

View solution in original post

8 REPLIES 8
tamerj1
Super User
Super User

Hi @cccarv82 
Here is the sample file with the solution https://we.tl/t-eHYz5Ypz3F

I hope this is what you're looking for

Actual Value = 
VAR Current_Value = Table_1[value]
VAR Current_Date = Table_1[date_day_by_day]
VAR CurrentItem_Table = CALCULATETABLE ( Table_1, ALLEXCEPT ( Table_1, Table_1[Name] ) )
VAR First_Date = MINX ( CurrentItem_Table, Table_1[date_day_by_day] )
VAR Last_Date = MAXX ( CurrentItem_Table, Table_1[date_day_by_day] )
VAR NumberOfDays = DATEDIFF ( First_Date, Current_Date, DAY )
VAR TotalNumberOfDays = DATEDIFF ( First_Date, Last_Date, DAY )
VAR DailyValue = DIVIDE ( Current_Value, TotalNumberOfDays )
RETURN
    Current_Value - DailyValue * NumberOfDays

1.png

WoW! Thank you @tamerj1 !! That's what i`m trying! I will now try to create a measure to recover this [Actual Value] by date to plot in a chart! 

I'm trying to build a burndown chart.

 

Again, thank you @tamerj1 !

tamerj1
Super User
Super User

Hi @cccarv82 

please provide more details. How does your report look like? Can share sample file?

Hi @tamerj1 !! 

 

First i have this column:

cccarv82_1-1651763708183.png

 

For each item i have a value, ok... then i expanded my table to be daily detailed and reach this:

 

cccarv82_2-1651764166274.png

 

Now i have the same value for each row but i want to add a column to show the new value where each day i subtract a measured value for each item so i can have Item 1 from 10 to 0 from 01/04/2022 to 14/04/2022 (in this example) and for Item 2 i will have from 10 to 0 from 15/04/2022 to 26/04/2022.

 

Here is the file:

PBI File with The tables 

 

I'll work on it and get back to you by tomorrow morning. Thank you

TYVM @tamerj1 ! I will keep trying from here too!

 

amitchandak
Super User
Super User

@cccarv82 , you can simply subtract a number

new column

 

new date = [Date] -[Number]

 

or

 

new date = [Date] -10

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

hi @amitchandak ! 

 

This way i will subtract the date. I need something like 

[Number] - [Measure]

But this doesnt work aswell because i will have the same result for all rows. I need to have a new result per row, like this:

cccarv82_0-1651751926475.png

 

the [number_by_date] is my new column where i have the result of the subtract but i i just use [number] - [measure] i will have the wrong result.

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors