Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi i am seeing some strange issue with the TopN function in power Bi
i have a dax formula
TOPN(
10, // <-- This is N. Change to 5 for Top 5, 20 for Top 20, etc.
VALUES(Fact_Table[EndDate_Time_Value]), -- <-- IMPORTANT: CHANGE THIS to the column you want to rank (e.g., VALUES('Product'[Product Name]))
CALCULATE(
SUM(Fact_Table[EndDate_Time_Value]),
Fact_Table[stage] = "4B",
Fact_Table[Produktion] = "OFF",
Fact_Table[_Flag.1] = 1
)
)
this works in the Dax Query studio
but in the visual i get this message
my table is below
is this a bug ?
Solved! Go to Solution.
Hello,
TOPN returns a table.
A measure cannot be a table of values but a single value. It works in query view as a DAX query returns a table. If you want to have it working in the DAX formula in Power BI you need to create a calculated table and not a measure. If you need a measure then you need to aggregate the values of this table. Hope I was clear, otherwise come back to me. You cann attach the pbix and I shall help but I need to know what you are trying to calculate.
Best
FB
@anwarbham - You are returning a table in TOPN and that cannot be produced as the output of a measure in a visual.
You will be able to use this DAX to create a Calculated table. Or you could use the TOPN as a Variable (VAR) and then you can RETURN a calculation that aggregates or selects something from this table stored in the variable.
If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!
Thanks for the kudos, in case it is ok like this can you mark it as a solution? Otherwise here I am Best, FB
@anwarbham - You are returning a table in TOPN and that cannot be produced as the output of a measure in a visual.
You will be able to use this DAX to create a Calculated table. Or you could use the TOPN as a Variable (VAR) and then you can RETURN a calculation that aggregates or selects something from this table stored in the variable.
If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!
Hi @anwarbham
This happens because TOPN returns a table
If this answers your questions, kindly accept it as solution and give kudos.
Hello,
TOPN returns a table.
A measure cannot be a table of values but a single value. It works in query view as a DAX query returns a table. If you want to have it working in the DAX formula in Power BI you need to create a calculated table and not a measure. If you need a measure then you need to aggregate the values of this table. Hope I was clear, otherwise come back to me. You cann attach the pbix and I shall help but I need to know what you are trying to calculate.
Best
FB
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
11 | |
10 | |
10 | |
10 |
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
8 |