I am trying to compute the NPV "Net Present Value" of a series of cash flows in PowerBI, using the XNPV formula, but want to be able to specify at which date the calculation should start.
I have 1 data table with 2 columns, "Month Ending", and "Value". The "Month Ending" column contains dates using the "Date" datatype, that are monthly for 40 years (following month end convention, I.E., 12/31/2022, 1/31/2023, 2/28/2023 etc...). The second column contains numbers of the data type "Fixed Decimal", representing the cash flow expected to occur in each monthly period. Additionally, I have a "What-If" parameter, of the "Decimal" data type, that can take a value between 0 and 1.
What I am able to do currently is compute the NPV of the entire cash flow series using the "XNPV" formula. What I want to be able to do is specify the exact starting point that the XNPV calculation should begin at.
Suppose we could create a parameter "Sale Date", that is is say 12/31/2024. I want a formula that would tell me what the XNPV is on 12/31/2024, using all cash flows that occur after 12/31/2024.
Ideally, I should be able to control this date using a slicer, and add it to a card on my display. The goal is to have the user drag a slider for the "Sale Date", and to see the value update on the card visual in real time. The end user should not have to modify any DAX expressions or Power Queries to change the result.
I have been struggling with this issue for a while, and cannot find any solutions that are dynamic in the way that I have described. Is what I am asking for even possible in PowerBI?
Thanks!
Related
I started working on Qlikview a week back and I am working on this dashboard.
I have a particular requirement which I am not able to achieve:
So, I have a calculated dimension "Categories" added in my script which based on certain conditions tags each name as SLEEPERS,STARS,WEAKLINKS etc.
Now, I have flagged the names based on certain condition which works fine.
The issue is, I want the sum of those flags on the level of calculated dimension CATEGORIES(SLEEPERS, STARS..etc) and my month field.
I am not able to achieve it because, the flag itself is a calculated field so sum of calculated field doesn't work. I tried using aggr, function but it returns zero for all rows. I am not sure why. in the aggr function I use the sum(Aggr(Flag,MONTH,Categories))
Can someone suggest a work around for this? I have attached the screenshot of the report for better understanding of the requirement
I have a field in my dashboard called outcome that displays the performance results for a doctor's office for multiple measures. A majority of the outcome values are rates and should be displayed as percentages. Unfortunately, there are two outcomes, "Utilization Management: Measure 3" and "Utilization Management: Measure 5" that are NOT rates, but actually number values.
Is there a way to display the outcome field in my table so that all 'Measures' that are NOT "Utilization Management: Measure 3" or "Utilization Management: Measure 5" get displayed as percentages, while the two aforementioned measures are displayed as number values?
Please do not get hung up on the appropriateness of combining rate and number values in the same field, as I've tried to have that conversation with my customer...they are insistent on this display ability and will not let it through UAT without it. Thanks.
Same question posed and packaged workbook attached for reference here.
One approach is to define a string valued calculated field that makes the number format part of the calculation logic. This solution does not play well with Measure Names and Measure Values, since you can't put string valued measures on the Measure Values shelf. But you can still build the view your customer wants, with a little effort.
First create a static set based on your field [Measure] (confusing choice of field name, by the way. You have a dimension named Measure.). Call it [Percentage Measures] and check off the ones you want displayed as percentages.
Then for each of your numeric measure fields that you want treated this way, make a corresponding calculated field that looks something like:
if attr([Percentage Measures]) then
str(round(sum([outcome]) * 100, 2)) + "%"
else
str(round(sum([outcome]),3))
end
This approach assumes you will use your calculation on views where your dimension named [Measure] is on some (non-filter) shelf. Adjust the round() function arguments as desired
I took a look at your workbook. It seems that it is not possible to dynamically format values. There is a feature idea here: https://community.tableau.com/ideas/1411 which I believe would allow you to do what you want.
A little background on the report:
This is a productivity report for our employees working at our business. We determine their productivity based on the duration of the visits with clients. Some of our employees offer group sessions. They charge each client within the group, even though they are only giving, for example, one hour of service, they can bill for 10 hours if there are 10 people in the group. We determine what service they gave by service codes.
So, I have two fields in this formula, a service code field and a duration field.
The duration field is initially a STRING field from the database, even though it only gives number data, so I change it to a numberVar. The service code field is also a string field, and it sometimes does contain characters and numbers.
What I need Crystal Reports to do is take the sum of the duration. However, if the service code is, say, "1000", it must first divide the duration by 3 before summing it. This is where I get caught up.
Here's my code for the duration:
local numbervar num1;
If GroupName ({billing_tx_charge_detail.v_SERVICE_CODE})="1530" then
num1 := ToNumber({billing_tx_charge_detail.v_duration})/3
else num1 := ToNumber({billing_tx_charge_detail.v_duration})
Then I do a separate formula for the sum, named sumDuration:
Sum(#duration)
I get the error that this field cannot be summarized. After searching Google for two days I have found that Crystal cannot summarize fields or formulas involving constants. If I simply say:
local numbervar num1;
num1 := ToNumber({billing_tx_charge_detail.v_duration})
then I can summarize #duration. What am I missing? It has to be something simple, but I'm just not seeing it. Is there a way to create a custom function to accomplish what I am trying to get here? Or is it even simpler than that?
One person suggested creating a SQL command in order to do the calculations before the data gets to the report. I am a SQL newb so I had no idea where to even begin with that.
If you are grouping by Service Code and placing the above formula in the footer you will only be computing {billing_tx_charge_detail.v_duration} for the last record in the group. If you are intending to use the formula and sum the results and place the results in the Service Code footer try the following. (basically remove the reference to group name)
If {billing_tx_charge_detail.v_SERVICE_CODE}) = "1530" then
ToNumber({billing_tx_charge_detail.v_duration})/3 else
ToNumber({billing_tx_charge_detail.v_duration})
You can use variables (num1) if you want to but they are not needed.
You can still use the second formula you referred to and place in the group footer OR you can place the first formula in details section, right click and insert a summary to the group footer. You can also place in the report footer if you need it to total there as well.
I have a list of financial metrics in column A, rest of the columns are the time periods the financial data is for.
Let's say I'm trying to calculate a ratio, but the financial metrics in A are not entirely unique, in the sense that a metric type may have more than one associated metric depending on how the company reports the metric.
For example, let's say I need Depreciation Expense on the income statement... that item may be reported as Depreciation, or DepreciationAndAmortization, or something else.
Any ideas how the formula in the ratio I'm trying to calculate can lookup the metric in A1, use the number immediately to the right as part of the formula... and if the metric Depreciation for example is 0, it would look for the next one I specify, like DepreciationAndAmortization, and use that one instead as the first one isn't reported.
If I understand correctly, this should do it:
=MAX(INDEX(B:B,MATCH("*depreciation*",A:A,)),INDEX(B:B,MATCH("*depreciation*",A:A,)+MATCH("*depreciation*",INDEX(A:A,1+MATCH("*depreciation*",A:A,)):INDEX(A:A,100+MATCH("*depreciation*",A:A,)),)))
If the alternatives are say in E2 and E3 then:
=MAX(VLOOKUP(E2,A:B,2,0),VLOOKUP(E3,A:B,2,0))
ie try both and take whichever is larger.
About your concern on the answer of Excel Hero that returns Value error, you can use the function "iferror" and returns "0" if the value/date you're looking for isn't available.
=IFERROR(MAX(INDEX(B:B,MATCH("*depreciation*",$A:$A,)),INDEX(B:B,MATCH("*depreciation*",$A:$A,)+MATCH("*depreciation*",INDEX($A:$A,1+MATCH("*depreciation*",$A:$A,)):INDEX($A:$A,100+MATCH("*depreciation*",$A:$A,)),))),0)
I am looking to create and use a gauge chart, but I am trying to figure how to compare selected vs the complete universe. For example, let's say I want to measure a monthly spending average of one department vs. the spending average of the entire organization. How do I make the organization average the segment marker? or make it a static variable that does not change with the selection?
As is the case with a lot of questions that pop up here, you can use set analysis to achieve this. In you gauge expression you could do something like this:
Assuming you are going to select one or more departments in the current state, you could do
percent_of_total_spending = avg({$}spending)/avg({1}spending)
The {} syntax is used in conjunction with the set identifiers $ and 1 to denote the the set of the current selections and the entire universe respectively. So the above expression will give you the percentage of average organizational spending for whatever departments you have selected.
You can use set modifiers in addition to the set identifiers to further customize what population you are including. See here for more information.
All you need to do is use set analysis and tell the expression what to ignore in the selections box.
Example:
Sum({<Month=, Year=>}Spending)
What the above is telling you is that it's taking the "Month" field and setting the selection for that specific expression to nothing, as well as the "Year" field. If you were to do the following:
Sum({<Month=, Year={"2014"}>}Spending)
It will calculate for that specific year, or even this
Sum({<Month=, Year={"2013","2014"}>}Spending)
Will make it calculate for both 2013 and 2014. Read up on the helpfile as well by pushing F1 and searching for set analysis.
So something like this will work for you
Sum(Spending) / Sum({<Month=, Year=>}Spending)