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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Vitor_sp_bo
Helper I
Helper I

count with parameter

Spoiler

good afternoon guys!

I have a promotion sheet, with a start and end date, and I made a count, but I need to put some parameters in this count, I need that if a product has more than one promotion in the same month and with the same end date (Example 10/23 and 10/23) I just count it as 1,

Any questions please, just ask

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Vitor_sp_bo ,

Do you mean using the parameters in Power bi desktop to count, I have an example here

I created some data:

vyangliumsft_0-1637129560464.png

Custom rules:

Use parameters to display the top N names, and calculate how many IDs the top N names in each group have.

Here are the steps you can follow:

1. Modeling – New parameter.

 

vyangliumsft_1-1637129560468.png

2. Create measure.

rank = RANKX(ALL('CountTable'),CALCULATE(SUM('CountTable'[Amount])),,ASC)
count=
COUNTX(FILTER(ALL(CountTable),'CountTable'[group]=MAX('CountTable'[group])&&[rank]<=[Parameter Value]),[group])

3. Result:

vyangliumsft_2-1637129560471.png

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Vitor_sp_bo ,

Do you mean using the parameters in Power bi desktop to count, I have an example here

I created some data:

vyangliumsft_0-1637129560464.png

Custom rules:

Use parameters to display the top N names, and calculate how many IDs the top N names in each group have.

Here are the steps you can follow:

1. Modeling – New parameter.

 

vyangliumsft_1-1637129560468.png

2. Create measure.

rank = RANKX(ALL('CountTable'),CALCULATE(SUM('CountTable'[Amount])),,ASC)
count=
COUNTX(FILTER(ALL(CountTable),'CountTable'[group]=MAX('CountTable'[group])&&[rank]<=[Parameter Value]),[group])

3. Result:

vyangliumsft_2-1637129560471.png

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

VahidDM
Super User
Super User

Hi @Vitor_sp_bo 

 

Can you post sample data as text and expected output?
Not enough information to go on;

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.
4. Relation between your tables

Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.