Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NandinAna
Frequent Visitor

DAX showing various results

Hi ,

I am finding problem with the results produced by below dax,one shows the correct results and other shows the wrong result and the only differnce here is All and Allselected,rest of the query is same.Please could someone help on this where i might be going wrong.

 

Which results in correct ranking data

 

.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]))

 

results in wrong ranking data

 

. 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])

)

, "-" )

 

1 REPLY 1
Sahir_Maharaj
Super User
Super User

Hello @NandinAna,

 

The difference between the two DAX formulas is that the first one uses ALLSELECTED function, while the second one uses ALL function. ALL function removes all filters from the specified column or table, while ALLSELECTED function removes all filters except the ones that come from the visual context.

 

Therefore, the reason why the results are different could be due to the different set of filters being applied to the table in each case.

 

To further investigate the issue, you could try comparing the filter context of the two measures by adding a table or matrix visual to your report, with the MemberFirm column and the two measures. This would show you the value of each measure for each MemberFirm, along with the filters applied to the visual.

 

Another thing to check is whether the relationship between the tables is correctly set up and whether the filters are being propagated as expected.

 

Hope this helps!


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors