Forum Discussion

Vitor_sp_bo's avatar
Vitor_sp_bo
Helper I
4 years ago
Solved

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

  • Anonymous's avatar
    Anonymous
    4 years ago

    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:

    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.

     

    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:

    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

2 Replies

  • 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/

  • Anonymous's avatar
    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:

    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.

     

    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:

    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