Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I would like to get help on the following formula where i need to calculate median time to sell nd rank it, for each user when they login,but i am getting the results wrong.
. Median_FIRM_TimeToSell_ALL_RANK =
var firm_userprincipalname = [MF_USERPRINCIPALNAME]
RETURN
IF([.Sum_FIRM_Sales_ALL] >= [.val_Rank_Threshold],
CALCULATE(
RANKX (
ALL ( IMPORT_SQL_monthly[MemberFirm] ),
CALCULATE ( MEDIAN( IMPORT_SQL_monthly[TimeToSell] ) ),
CALCULATE ( MEDIAN( IMPORT_SQL_monthly[TimeToSell] ), LOOKUP_MF_USERS[PrincipalName] = firm_userprincipalname )
,ASC),
OR(IMPORT_SQL_monthly[CurrentStatus]="Sold", IMPORT_SQL_monthly[CurrentStatus]="SaleComplete"),
USERELATIONSHIP( IMPORT_SQL_monthly[DateSold], TBL_CALENDAR_date[Date]),
USERELATIONSHIP( IMPORT_SQL_monthly[MemberFirm], LOOKUP_MF_USERS[firm])
)
, "-" ).
Please could someone help on this.
@NandinAna Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
Hello,
Thanks for your reply.I need some one to talkthrough where i am going wrong.So i have two app created one for our internal purpose and other for external customers where they can view thier sales and other stuff for their company.So problem here is the calculation of the rank based on the time to sell is showing correct in our internal view but its wrong in the clients view except for this all the other calculations are exact same in both the view. So above is the calculation for determining rank of the company each year based on time to sell.
The below is the example where the time to sell column is incorrect for a firm Parissteele,
Formula used for above,
. Median_FIRM_TimeToSell_ALL_RANK =
var firm_userprincipalname = [MF_USERPRINCIPALNAME]
RETURN
IF([.Sum_FIRM_Sales_ALL] >= [.val_Rank_Threshold],
CALCULATE(
RANKX (
ALL ( IMPORT_SQL_monthly[MemberFirm] ),
CALCULATE ( MEDIAN( IMPORT_SQL_monthly[TimeToSell] ) ),
CALCULATE ( MEDIAN( IMPORT_SQL_monthly[TimeToSell] ), LOOKUP_MF_USERS[PrincipalName] = firm_userprincipalname )
,ASC),
OR(IMPORT_SQL_monthly[CurrentStatus]="Sold", IMPORT_SQL_monthly[CurrentStatus]="SaleComplete"),
USERELATIONSHIP( IMPORT_SQL_monthly[DateSold], TBL_CALENDAR_date[Date]),
USERELATIONSHIP( IMPORT_SQL_monthly[MemberFirm], LOOKUP_MF_USERS[firm])
)
, "-" )
Actually the time to sell for the firm parie steele for the year 2013 should be 37 and not 120.I have managed to get the median days right now,again when I try to rank it as below but still dint get the rnking quite right.
testmediantimetosell =
var firm_userprincipalname = [MF_USERPRINCIPALNAME]
RETURN
IF([.Sum_FIRM_Sales_ALL] >= [.val_Rank_Threshold],
CALCULATE(
CALCULATE ( CALCULATE ( MEDIAN( IMPORT_SQL_monthly[TimeToSell] ), LOOKUP_MF_USERS[PrincipalName] = firm_userprincipalname )),
OR(IMPORT_SQL_monthly[CurrentStatus]="Sold", IMPORT_SQL_monthly[CurrentStatus]="SaleComplete"),
USERELATIONSHIP( IMPORT_SQL_monthly[DateSold], TBL_CALENDAR_date[Date]),
USERELATIONSHIP( IMPORT_SQL_monthly[MemberFirm], LOOKUP_MF_USERS[firm])
))
Correct display of time to sell:
Formula used for the above,
.RankMedian_TimeToSell = IF([.Count_Sales_ALL] < 10, "-", RANKX(ALLSELECTED(IMPORT_SQL_monthly[MemberFirm]),[.Median_TimeToSell_ALL],,ASC))
.Median_TimeToSell_ALL = CALCULATE(MEDIAN(IMPORT_SQL_monthly[TimeToSell]),OR(IMPORT_SQL_monthly[CurrentStatus]="Sold",IMPORT_SQL_monthly[CurrentStatus]="SaleComplete"), USERELATIONSHIP('TBL_CALENDAR_date'[Date],IMPORT_SQL_monthly[DateSold]), ALL(IMPORT_SQL_monthly[OrganisationId]), USERELATIONSHIP(IMPORT_SQL_monthly[SellingPrice_bin_25K_label], TBL_SLICE_Price[Axis]))
User | Count |
---|---|
40 | |
26 | |
22 | |
16 | |
15 |
User | Count |
---|---|
54 | |
35 | |
18 | |
17 | |
15 |