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
fabo
Advocate III
Advocate III

Error in TOP 3 Ranking with DAX

Hello there!

 

I'm just learning DAX so maybe this question isn't hard at all.  I found this Top 3 ranking example in other site X.  I tried to implement it from the scratch but I got an error I can't fix neither understand.

 

Table:

 

facts.PNG

 

 

 

 

 

 

 

 

 

Measures:

 

Sum Value = SUM(Test[Value])

 

Rank Name =
IF(
   HASONEVALUE(Test[Name]),
   RANKX(ALL(Test[Name], Test[Value]), [Sum Value])
   )

 

Top 3 Cases =
IF(
   HASONEVALUE(Test[Name]),
   IF(
      [Rank Name] <= 3,
      [Sum Value]
   )
)

 

The error is highlighted in the measure Top 3 Cases:

 

error.PNGtable.PNG

 

The error is "the syntax of '[Sum Value] is incorrect".  

 

I downloaded the original files from that site X and the same error occurs.  I reviewed the comments looking for clues and I got nothing.

 

Maybe something in my Power BI Desktop settings is wrong.  Or maybe something else.  Any ideas, please?

 

Greetings!

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi ,

I believe that is relatef with regional settings try to change your formula from:
[Rank Name] <= 3,
[Sum Value]

To

[Rank Name] <= 3,0,
[Sum Value]

Still no sure why but with my regional.setting when I need to add numbers to my syntax always need to add the decimals, probably because the decimal.symbol (comma) is the same as the separator in the formulas

Check if it works.

Regards,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi ,

I believe that is relatef with regional settings try to change your formula from:
[Rank Name] <= 3,
[Sum Value]

To

[Rank Name] <= 3,0,
[Sum Value]

Still no sure why but with my regional.setting when I need to add numbers to my syntax always need to add the decimals, probably because the decimal.symbol (comma) is the same as the separator in the formulas

Check if it works.

Regards,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix!

 

It works!  You were right.  It was a regional setting issue.  The code seems to be confunsing at first glance because 0 looks like the true argument in the IF statement and [Sum Value] looks like the false argument.  

 

Fortunately, we can use several lines and spacing to make it clearer.

 

Thank you for your help!

 

Best regards!

fabo

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.