Power BI, Line Chart with Base Value 100 - powerbi

I need to build a line chart that is supposed to show the cumulative increase from Day 1 to the End.
An Example would be like this:
Date Capital Value
31-Jan 237 100.00
28-Feb 250 105.48
31-Mar 210 88.60
30-Apr 300 126.58
In other words, is dividing every value by the first value, not of the whole table but the dates that are been displayed in the chart. The first date is dynamically changed as time passes, making it impossible to fix the formula to 31-Jan for example
Kind Regards

Try this measure:
% Capital running total in Date =
VAR runtotal =
CALCULATE (
SUM ( 'YourTable'[Capital] ),
FILTER (
ALLSELECTED ( 'YourTable'[Date] ),
ISONORAFTER ( 'YourTable'[Date], MAX ( 'YourTable'[Date] ), DESC )
)
)
VAR baseval =
CALCULATE (
SUM ( 'YourTable'[Capital] ),
FIRSTDATE ( ALL ( YourTable[Date] ) )
)
RETURN
DIVIDE ( runtotal, baseval )
Note that for calculating the Running Total Power BI can help you with a Quick Measure.

Related

SUMMARIZE or SUM values based on Date fields in another table

I am trying to do a burndown graph on PowerBI.
My data is a list of tasks. Each task has a numerical value (EFFORT) assigned to it and there is a total amount of effort for any given month (sum of all EFFORT). As tasks as set to DONE, the ongoing effort should be deducted from a running total and that value used to plot a graph. I have 3 columns
I would like to have measure to calculate EFFORT REMAINING for each date, i.e.
EFFORT REMAINING = TOTAL EFFORT - (EFFORT WHEN TASKS ARE DONE FOR EACH DAY)
For example,
I did get the consecutive dates displaying:
Burndown = CALENDAR(DATE(2022,7,1),DATE(2022,7,31))
and also the total effort (starting value)
TOTAL EFFORT = SUM(Issues[EFFORT])
Now for each date in table, I need to minus the accumulating total of EFFORT when the status is set to DONE
EFFORT REMAINING = Burndown[TOTAL EFFORT]-SUM(Issues[EFFORT]="DONE" ....
Im stuck after this last point. Can anyone help, please?
you are so close to the answer ). Convert SUM(Issues[EFFORT]="DONE" to:
CALCULATE(
SUM(Issues[EFFORT])
, SUM(Issues[Status]="DONE"
)
Have a nice day.
Please try this measure:
Please ensure that (1-Many) relationship is created between Burndown [Date] and Issues[ISSUE_CREATED] columns.
EFFORT REMAINING =
VAR TblSummary =
ADDCOLUMNS (
SUMMARIZE ( Issues, Burndown[Date] ),
"Total Effort", CALCULATE ( SUM ( Issues[EFFORT] ) ),
"Tasks Completed", CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" ),
"Effort Remaining",
CALCULATE ( SUM ( Issues[EFFORT] ) )
- CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" )
)
VAR Result =
SUMX ( TblSummary, [Effort Remaining] )
RETURN
Result
After that, you can create a clustered column chart, and put [Date field] on calendar table on X_axis and put 'EFFORT REMAINING' measure on Y_axis(Value axis) to see the result.
I hope It solves your problem.
Bonus Info:
If you want to see your Summary table, create a "New Table" and paste this code:
Summary_Table =
VAR TblSummary =
ADDCOLUMNS (
SUMMARIZE ( Issues, Burndown[Date] ),
"Total Effort", CALCULATE ( SUM ( Issues[EFFORT] ) ),
"Tasks Completed", CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" ),
"Effort Remaining",
CALCULATE ( SUM ( Issues[EFFORT] ) )
- CALCULATE ( SUM ( Issues[EFFORT] ), Issues[STATUS] = "DONE" )
)
VAR Result =
SUMX ( TblSummary, [Effort Remaining] )
RETURN
TblSummary
The result It produces:
Note: I have limited access to your data sets as you shared above. The result will be exact with your full dataset.

calculate the difference between first and last value of each Id and count those with 10% decrease in DAX Power BI

have a simple table like this
ID value date
A 100 2020-01-01
B 80 2019-01-01
A 90 2022-01-01
A 130 2021-01-01
B 100 2021-01-01
and want to know how many IDs had 10% increase within a selected time period, IDs might not necessarily have an entry on Min(Date) or Max(Date), I'd like to know the difference between first and last value within the selected time period
I came up with something like this but not sure if it's working :
Measure=
Var FirstValue=
SUMX (
VALUES( table [ID] ),
CALCULATE ( MIN ( table[value]), FIRSTDATE ( 'Date'[DATE] ) )
)
Var LastValue =
SUMX (
VALUES( table[ID] ),
CALCULATE ( MIN ( table[value] ), LASTDATE ( 'Date'[DATE]) )
)
Return sumx(table,if( (FirstValue -LastValue )/FirstValue> 0.1 , 1,0)
)

Power BI matrix grand totals wont add up

I'm new to Power BI and facing this issue with a Power BI report grand totals of these columns won't add up. Any help is much appreciated, below are the formulas
Rolling 3 Months =
CALCULATE (
SUM ( Deliveries[NetRevenue] ),
DATESBETWEEN (
Deliveries[DeliveryDate],
MAX ( Deliveries[DeliveryDate] ) - 90,
MAX ( Deliveries[DeliveryDate] )
)
)
Prior 3 Months =
CALCULATE (
SUM ( Deliveries[NetRevenue] ),
DATESBETWEEN (
Deliveries[DeliveryDate],
MAX ( Deliveries[DeliveryDate] ) - 180,
MAX ( Deliveries[DeliveryDate] ) - 90
)
)
Screenshot of the result
This is likely because MAX ( Deliveries[DeliveryDate] ) is not the same for every row.
The maximum is evaluated within the local filter context, not over the entire Deliveries table (or the subset of the table that matches your filter settings).
I'm guessing you probably want to define a variable to use as your date rather than calculating it (potentially) differently for each row in your matrix. E.g.
Prior 3 Months =
VAR LastDate =
CALCULATE ( MAX ( Deliveries[DeliveryDate] ), ALLSELECTED ( Deliveries ) )
RETURN
CALCULATE (
SUM ( Deliveries[NetRevenue] ),
DATESBETWEEN ( Deliveries[DeliveryDate], LastDate - 180, LastDate - 90 )
)
You might be able to use TODAY() instead of that LastDate calculation, depending on your particular situation.

How to get divide a column by its start value based its filter date range

date return
1/1/2010 1.01
2/1/2010 1.02
3/1/2010 1.03
4/1/2010 1.04
5/1/2010 1.05
6/1/2010 1.06
7/1/2010 1.07
8/1/2010 1.08
9/1/2010 1.09
Hi, There,
I have cumulative return data (factor_return). I want a measure = return / start_return
where start_return is the return of the earliest date in the filtered date range.
Thanks
I tried this, but got complained "cannot find name factor_return[ return]". Please help.
Measure =
VAR start_return =
CALCULATE (
VALUES ( factor_return[ return] ),
FILTER (
ALLSELECTED ( factor_return[date] ),
factor_return[date] = MIN ( factor_return[date] )
)
)
RETURN
DIVIDE ( factor_return[ return], start_return )
Well first, your error means that you misspelled your column. I can see you added a white space before 'return', there is a difference between [ return] and [return]. Note the space in the first example.
Secondly, your formula wouldn't get you what you want because the MIN() statement would be affected by the filtercontext outside of the current filtered table context. It would search for the min date in a table of only 1 row (the current date row).
The following measure will work for you:
Measure =
VAR start_return = CALCULATE(VALUES(factor_return[return]), FILTER(ALLSELECTED(factor_return), factor_return[date] = MINX(ALLSELECTED(factor_return), factor_return[date])))
RETURN
DIVIDE(SELECTEDVALUE(factor_return[return]), start_return)
Measure 2 in the following screenshot shows the value of VAR start_return.
Hope this helps!
I'd do it like this:
Measure =
VAR start_date =
CALCULATE (
MIN ( factor_return[date] ),
ALLSELECTED ( factor_return )
)
VAR start_return =
CALCULATE (
SELECTEDVALUE ( factor_return[return] ),
factor_return[date] = start_date
)
RETURN
DIVIDE ( SELECTEDVALUE ( factor_return[return] ), start_return )
This calculates the first date within your filter, looks up the return on that date, then divides the current return by that first return.

Cumulative number of entries in dates range

I'm trying to get cumulative number of unique IDs in given timeframe.
My DAX look like this:
Cumulative = CALCULATE(SUM(Data[ID]));DATESBETWEEN(Data[ack_date];DATE(YEAR(NOW());4;1);DATE(YEAR(NOW());11;30)))
There is similar measure for Year-1: [YEAR(NOW())-1]
What I want to achieve is area chart showing growing number od IDs in time comparing same periods this and previous year. When I give those measures as Values for chart and "ack_date" as its Axis what I get is values comparison month by month but not cumulative, just value for certain month.
Try this code. Adjust for year -1.
=
CALCULATE (
DISTINCTCOUNT ( Data[ID] ),
FILTER (
ALL ( Data ),
AND (
Data[Ack_date] <= MAX ( Data[Ack_date] ),
AND (
Data[Ack_date] <= DATE ( YEAR ( NOW () ), 11, 30 ),
Data[Ack_date] >= DATE ( YEAR ( NOW () ), 4, 1 )
)
)
)
)