Substract not working as desired in powerBI - powerbi

I have done calculated column:
Delta = OnBoth[Values2022/03] - OnBoth[Trans Amount $ (Pos-Rev)]
But the substract sometimes gives incorrect values, the total should be 2k but it is 14k, see picture

Why don't you try this for your Sum Of Delta Measure without building additional column to calculate difference.
Sum Of Delta =
SUMX ( OnBoth, [Values2022/03] - [Trans Amount $ (Pos-Rev)] )

Related

How to calculate the cumulative total of an average (calculated column)

I'm having a hard time to calculate the running / cumulative total of average values...
My idea is to emulate a sales campaign for a product that never had one, using the average by day of all the products from an specific brand; problem is the code I made is only repeating the numbers from the average, it's not summing them up:
This is how it's now:
This is how it should be:
I managed to filter the values I want to calculate the average for, and that's for an specific brand (this is not going to be replicated to all products, and in the end I want to merge this in another calculated column which will calculate the goal for all the products (including the exception, which are the ones that never had a sales campaign before).
here's the code for the average:
AllPlutoProductsAverage = MAXX(FILTER('f_Leads(teste2)', [percentage] = EARLIER(d_CT_Leads_RT[percentage]) && 'f_Leads(teste2)'[group_name]="Pluto"), 'f_Leads(teste2)'[registers_per_day] )
And here's the code for the cumulative/running total column:
VAR _NoCampaign_RT =
CALCULATE(
MAX( 'd_CT_Leads_RT'[AllPlutoProductsAverage ] ) ,
FILTER( 'f_Leads(teste2)' ,
AND( 'f_Leads(teste2)'[group_name] = d_CT_Leads_RT[group_name] ,
'f_Leads(teste2)'[course] = d_CT_Leads_RT[course]
) &&'f_Leads(teste2)'[course_closed_percentage] = d_CT_Leads_RT[percentage]
)
)
Any ideas on how I fix that...?
Thanks in advance!! :))
I tried:
quick measure for running totals, didn't work
custom code for running totals, still repeated the values
creating a separate measure for average and then mentioned it on the column's running total code, same result
tried building up a running total code by adding the average calculation into it as a variable, didn't work either
tried exporting the calculation to a measure, didn't work either
And by 'didn't work' I mean the column No_PreviousCampaign still shows the repeated values from AllPlutoProductsAverage

Cumulative running total based on count PowerBI measure

I'm trying to create a chart with 3 informations:
Total cases
% of total per day
cumulative % running total
The first two informations are working, but I can't make the third one work, my chart look like this
And I need it to look like this
Basically, the upper line is a cumulative sum of the lower line, the problem is that the values of the bars are just a count on my table and the lower line I made using the PowerBI function "Show as % of total"
I've tried googling but no luck with this one, tried this measure but didn't work:
Running Total MEASURE =
CALCULATE (
COUNT ( 'Primes Encerrados'[Nome Cliente] ),
FILTER (
ALL ( 'Primes Encerrados' ),
'Primes Encerrados'[Data] <= MAX ( 'Primes Encerrados'[Data] )
)
)
Use a the Quick Measure feature to get your running total formula:
Power BI will generate this formula for you:
Primes encerrados running total in Dias =
CALCULATE(
SUM('Geral'[Primes encerrados]),
FILTER(
ALLSELECTED('Geral'[Dias]),
ISONORAFTER('Geral'[Dias], MAX('Geral'[Dias]), DESC)
)
)
Add the measure to your chart and show it as % of Grand Total like you did with the first line

Power BI returning value >0 for when dividing by 0

Trying to calculate YTD Percent off an imported data set, but receiving a value >0 for division where there is no budget or expenditure.
I have tried both of the following dax measures to calculate that column:
Percent = divide(Actuals[Actuals],Budget[Budget])
Percent = IFERROR(Acutals[Acutals]/Budget[Budget], blank())
See photo here:
It appears that these aren't exactly zero just very small (possibly due to floating-point error or something similar). So it isn't actually dividing zeros.
One option to avoid this would be to round your numbers to some number of decimal places before trying to divide. E.g.
Percent = DIVIDE ( ROUND ( Actuals[Actuals], 2 ), ROUND ( Budget[Budget], 2 ) )

PowerBI - Running Total on Time-Independent Data Column

I was attempting to employ the formulas here to calculate a running total of a column in PowerBI. However, my data is time-independent. In addition, every other running total calculation I've seen for PowerBI has been in reference to a date field. The target column is a "Frequency" column, and represents the estimated frequency of the event represented by each record. How do I generate a cumulative total of these frequencies, from lowest frequency to greatest? This is used to generate an exceedence curve for the consequences of events based on the running frequency total, called an F-N curve.
Per this site: https://www.daxpatterns.com/cumulative-total/, I was able to generate the following measure:
Measure_cumF =
CALCULATE (
sum([content.F]),
FILTER (
ALLSELECTED( Sheet1),
Sheet1[Content.N] >= MIN ( Sheet1[Content.N] )
)
)
"MIN" allows the cumulative sum of "Content.F" to start at the row containing the highest value of the desired sorting list, in this case "Content.N". "MAX" will start the cumulative sum at the row containing the lowest value of "Content.N".
"ALLSELECTED" applies the current filters to the measure. Replace with "ALL" to have a static value that always returns the cumulative sum of the entire column.

Power bi: Calculate the running total and multiply by each months value

I haven't found anything on this, but maybe someone has an idea.
I want to calculate the running total of an amount, and then get a measure that allows to show it per month. This then should be multiplied by a value for that month. 
The data I have is looking like this:
Now i want to get as result:
So, sum up the amounts and then calculate it with this months value. Is this possible as a measure?
Thanks in advance for any help!
Here is one way to do it:
//amount_total measure calculates total amount
amount_total = SUMX(data, data[amount])
//value_total measure calculates total value
value_total = SUMX(data, data[value])
//amount_rt measure calculates running total multiplied by value
amount_rt =
VAR cur_date = MAX(data[date])
VAR rt = CALCULATE(
[amount_total],
FILTER(
ALL(data),
data[date] <= cur_date
)
)
RETURN rt * [value_total]
Result: