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
Anonymous
Not applicable

Summarized columns

Hi Team, I am trying to summarize on multiple columns but always it's throwing same error. I didn't understand the cause.

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

By mistake but its not variable. but still it's showing same issue.

 

View solution in original post

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

HI  @Anonymous 

For your formula, this returns a table not a value

https://docs.microsoft.com/en-us/dax/topn-function-dax

Returns the top N rows of the specified table.

 

then for your measure , it should like this:

Ranking 1=

var test =
     TOPN(
50,
SUMMARIZECOLUMNS(
 
'Provider'[Name],
"Paid_Amount", 'Fact Claim'[Paid Amount],
"Unique_Patient", 'Fact Claim'[Unique Patient],
"Total_Claim_Services", 'Fact Claim'[Total Claim Services],
"Avg_Amount_Paid_by_Service", 'Fact Claim'[Avg Amount Paid by Service]
),
[Paid_Amount],
0,
'Provider'[Name],
1
)
Return
<Your expressiom>
 
 
if you still have the problem, please share your sample pbix file and your expected output.
 
Regards,
Lin
Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Please find the sample pbix file and Expected output. Here i want to show Top 50 providers on rank wise while sorting the paid amount.

Note: Here my orginal source is tabular model so i can't create index column so we need to apply dax to show ranks top 50 records , i have already filtered out Top 50 records just i want show one column for Ranks.

Rankx = RANKX(ALL('Fact_Claim_Base_Vw'),[Paid Amount],,DESC,Dense)-- it's showing duplicate records.
Here am using another measure to show one column for ranks
evaluate
ADDCOLUMNS(test, "Rank", countrows(FILTER (TEST,[Paid_Amount]>=EARLIER([PAID_AMOUNT]) )
))
it's working fine in while am writing tabular database level but power bi not working.
 
AllisonKennedy
Super User
Super User

What are you trying to achieve?

 

You're using a VAR variable to define a table as a variable, but you're missing a 

RETURN

dax expression here

 

You need to add the RETURN value, based on what you want the measure to actually do.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

By mistake but its not variable. but still it's showing same issue.

 

Assuming this is just a variable in a longer expression, you are not using SUMMARIZECOLUMNS correctly.  Please see this article - https://www.sqlbi.com/articles/introducing-summarizecolumns/

You are naming your new columns, but you seem to be referencing columns after those (instead of measures).  For example, is 'Fact Claim'[Paid Amount] a column or a measure on that table.  If a measure, consensus is not to list the table with measures (so people that review your code will know it).  If a column, you need to have an aggregation, potentially wrapped in a CALCULATE( ) to get context transition, or just reference an existing measure.

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.