In power BI there is two options to calculate quartile. Exclusive & Inclusive. I'm unable to understand the difference between two. Can you please help me understand using one example?
Check info from https://dax.guide/percentile-exc/:
PERCENTILE.EXC computed the k-th percentile, exclusive
PERCENTILE.INC computed the k-th percentile, inclusive
Both functions rank the N values from 1 (lowest) to N (highest),
then determine the possibly-non-integer calculated rank for the
specified percentage argument K (a decimal number between 0.00 and
1.00), and finally use linear interpolation between the closest integer-rank values of the data array.
For PERCENTILE.EXC the calculated rank is K*(N+1) For PERCENTILE.INC
the calculated rank is K*(N-1)+1
MEDIAN corresponds to PERCENTILE.INC with k=0.50
DEFINE
TABLE SampleData = { 2, 4, 4, 4, 5, 5, 7, 9 }
EVALUATE
{
( "AVERAGE", AVERAGE ( SampleData[Value] ) ),
( "MEDIAN", MEDIAN ( SampleData[Value] ) ),
( "PERCENTILE.EXC 0.25", PERCENTILE.EXC ( SampleData[Value], 0.25 ) ),
( "PERCENTILE.INC 0.25", PERCENTILE.INC ( SampleData[Value], 0.25 ) ),
( "PERCENTILE.EXC 0.50", PERCENTILE.EXC ( SampleData[Value], 0.50 ) ),
( "PERCENTILE.INC 0.50", PERCENTILE.INC ( SampleData[Value], 0.50 ) ),
( "PERCENTILE.EXC 0.75", PERCENTILE.EXC ( SampleData[Value], 0.75 ) ),
( "PERCENTILE.INC 0.75", PERCENTILE.INC ( SampleData[Value], 0.75 ) )
}
Related
Can anyone help me with this formula?
Calculate formula not totaling
Rev SWLY2 =
CALCULATE (
SUM ( 'Fact Table'[[Revenue Net]]] ),
FILTER (
ALL ( DateTable ),
DateTable[WeekID] = SELECTEDVALUE ( DateTable[WeekID] ) - 52
)
)
For the total, SELECTEDVALUE ( DateTable[WeekID] ) returns a blank because there are multiple weeks within the filter context.
Try using MAX in the case instead of SELECTEDVALUE.
Edit: I think this should work as you'd expect:
Rev SWLY2 =
CALCULATE (
SUM ( 'Fact Table'[[Revenue Net]]] ),
FILTER (
ALL ( DateTable ),
DateTable[WeekID] + 52 IN VALUES ( DateTable[WeekID] )
)
)
Note that VALUES is a list when there are more than one values.
Trying to return loss provision ratio (loan provision/total assets) but for 1 year in the past based on the most recent date available. MO[Total]="11" is total loss provision, MO[Total]="15" is total assets, MO[Data_Date] is all dates. When I break these apart I get correct values, but when I combine them into a divide function it always returns blank. See code below:
Loss Provision BS LY =
DIVIDE (
CALCULATE (
SUM ( MO[Total] ),
MO[Line_Number] = "11",
DATEADD ( LASTDATE ( MO[Data_Date] ), -1, YEAR )
) * -1,
CALCULATE (
SUM ( MO[Total] ),
MO[Line_Number] = "15",
DATEADD ( LASTDATE ( MO[Data_Date] ), -1, YEAR )
)
)
I have a measure in which i am dividing total number of contractual months from total number of months. I am getting correct result, but the total in the bottom is not correct.
The first column is a unique ID, Third and fourth columns are numerator and denominator, Second column is the result of the division, I want to count those IDs, where the division is between 0.75 and 1.00
Here are my calculations
Var Check=DIVIDE([Month of Engagement],[Months In Contract L30])
RETURN
IF(HASONEVALUE('Fact - TABLE'[ID]),IF(Check>=0.75 && Check<=1.00,DISTINCTCOUNT(ID),0),SUMX('Fact - TABLE',IF(Check>=0.75 && Check<=1.00,DISTINCTCOUNT(ID),0)))
Please let me know, how to solve this.
For Total, you should change 3th parameter of IF to:
CALCULATE (
SUMX (
CALCULATETABLE (
tab,
FILTER (
ALL ( tab ),
VAR __Check =
DIVIDE ( 'Tab'[Month of Engagement], Tab[Months In Contract L30] )
RETURN
__Check < 1
&& __Check > 0.75
)
),
1
)
)
Below my test example (for testing only I have put check variable in first IF
IF ( Check >= 0.75 && Check <= 1.00, Check, 0 ) to see if check calculation is correct):
Measure =
VAR Check =
DIVIDE (
SUM ( 'Tab'[Month of Engagement] ),
SUM ( Tab[Months In Contract L30] )
)
RETURN
IF (
HASONEVALUE ( 'Tab'[ID] ),
IF ( Check >= 0.75 && Check <= 1.00, Check, 0 ),
CALCULATE (
SUMX (
CALCULATETABLE (
tab,
FILTER (
ALL ( tab ),
VAR __Check =
DIVIDE ( 'Tab'[Month of Engagement], Tab[Months In Contract L30] )
RETURN
__Check < 1
&& __Check > 0.75
)
),
1
)
)
)
Measure =
VAR Check =
DIVIDE (
[Month of Engagement] ,
[Months In Contract L30]
)
RETURN
IF (
HASONEVALUE ( 'Tab'[ID] ),
IF ( Check >= 0.75 && Check <= 1.00, Check, 0 ),
CALCULATE (
SUMX (
CALCULATETABLE (
'Tab',
FILTER (
ALL ( 'Tab' ),
VAR __Check =
DIVIDE ( [Month of Engagement], [Months In Contract L30] )
RETURN
__Check >=0.75
&& __Check <=1.00
)
),
1
)
)
)
Here are the brief definitions
Month of Engagement:= CALCULATE(COUNTROWS(
SUMMARIZE('table','table'[MONTH_OF_ENGAGEMENT],"Count",DISTINCT('table'[MONTH_OF_ENGAGEMENT]))),'table'[FREQUENCY_FLAG]="Y")+0
Here MONTH_OF_ENGAGEMENT is value extracted from a date as YYYYMM
Months In Contract L30:=
Var DBRefreshDate30= [Database Refresh Date]-30
RETURN
DATEDIFF(DBRefreshDate30,[Database Refresh Date],MONTH)+1
Now basis on dividing Month of Engagement from Months In Contract L30, i am deriving a percentage, and checking if that percentage lies between 0.75 and 1.00
Trying to add a measure in PowerBI that calculates the rolling 12-month sum of sales and the measure works fine up until the most recent 12 months worth of data. Not sure what's causing this error. Below is the data and code in PowerBI I'm using.
TTM MRR =
CALCULATE (
SUM ( MRR[MONTHLY_REV] ),
FILTER (
ALL ( MRR[CLOSE_MONTH] ),
AND (
MRR[CLOSE_MONTH] <= MAX ( MRR[CLOSE_MONTH] ),
DATEADD ( MRR[CLOSE_MONTH], 1, YEAR ) > MAX ( MRR[CLOSE_MONTH] )
)
)
)
Data:
[Excel Data]
It might be easier with DATESINPERIOD.
TTM MRR =
VAR PeriodEnd = MAX ( MRR[CLOSE_MONTH] )
RETURN
CALCULATE (
SUM ( MRR[MONTHLY_REV] ),
DATESINPERIOD ( MRR[CLOSE_MONTH], PeriodEnd, -12, MONTH )
)
enter image description hereI have daily values of closing balances of balance sheet. I want to have a measure which calculates the percentage change between two dates. The issue is that on weekdays the values are empty. So I have written the following measure which works when there are no filters, but when I place a date filter, the values of the measure become zeros.
Change_BS %(daily) =
IF (
SUM ( 'DB Daily_BS'[Value] ) = 0,
0,
IF (
SUM ( 'Date'[Weekday] ) = 1,
DIVIDE (
SUM ( 'DB Daily_BS'[Value] )
- CALCULATE ( SUM ( 'DB Daily_BS'[Value] ), DATEADD ( 'Date'[Date], -3, DAY ) ),
CALCULATE ( SUM ( 'DB Daily_BS'[Value] ), DATEADD ( 'Date'[Date], -3, DAY ) )
),
DIVIDE (
SUM ( 'DB Daily_BS'[Value] )
- CALCULATE ( SUM ( 'DB Daily_BS'[Value] ), PREVIOUSDAY ( 'Date'[Date] ) ),
CALCULATE ( SUM ( 'DB Daily_BS'[Value] ), PREVIOUSDAY ( 'Date'[Date] ) )
)
)
)
de a new Column called BS_Value which fills in the gaps for the weekends.
BS_Value =
var wday = MOD(WEEKDAY(Balance[Date]);7)
var daysBack = IF(wday < 2; wday + 1)
return CALCULATE(SUM(Balance[Value]);Balance[Date] = EARLIER(Balance[Date]) - daysBack)
Based on this column I made BS-Change what is the increment/decrement form previous:
BS_Change = Balance[BS_Value] - CALCULATE(SUM(Balance[BS_Value]);Balance[Date] = EARLIER(Balance[Date]) - 1)
End result:
You can now make measures or other columns based on those values. I need to say a more dynamic solution is possible where we would go for a lookup of the last value not zero. I did not do this because I can imagine the balance is zero and it would then skip those values.