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
cristianml
Post Prodigy
Post Prodigy

DAX Formula for COUNT (Resources)

Hi,

I need to Count The quantity of resources from a query. The thing is that it has duplicated lines due to diferent reasons, Ctegory, Unit, Location, ETC.  Follow a example of what info has the table for reference..  I tried with the following formula but in same cases duplicates the quantity as it has various "Units" .. 

COUNTX(FILTER('Resource Actual','Resource Actual'[Category]="Hours" && 'Resource Actual'[Quantity]>8),'Resource Actual'[Quantity])

 

In this case I need that the formula COUNTS 1 for "Carlos" . 

 

LocationCurrency:NameUnitLevelCategoryQuantity
ArgentinaUnited States DollarCarlosLocalAnalystHours           40.00
ArgentinaUnited States DollarCarlosLocalAnalystPayroll   16,000.00
ArgentinaUnited States DollarCarlosLocalAnalystCost rate        400.00
ArgentinaUnited States DollarCarlosUSAnalystHours           21.00
ArgentinaUnited States DollarCarlosUSAnalystPayroll     8,400.00
ArgentinaUnited States DollarCarlosUSAnalystCost rate        400.00
ArgentinaUnited States DollarCarlosInternationalAnalystHours           88.00
ArgentinaUnited States DollarCarlosInternationalAnalystPayroll   35,200.00
ArgentinaUnited States DollarCarlosInternationalAnalystCost rate        400.00
ArgentinaUnited States DollarFedericoLocalSeniorHours           30.00
ArgentinaUnited States DollarFedericoLocalSeniorPayroll   15,000.00
ArgentinaUnited States DollarFedericoLocalSeniorCost rate        500.00
ArgentinaUnited States DollarFedericoInternationalSeniorHours           93.00
ArgentinaUnited States DollarFedericoInternationalSeniorPayroll   46,500.00
ArgentinaUnited States DollarFedericoInternationalSeniorCost rate        500.00

 

Any idea / Trick ?

 

Thanks, 

1 ACCEPTED SOLUTION

Hi @cristianml ,

 

To create a measure as below.

Measure = 
VAR su =
    SUMMARIZECOLUMNS (
        Sheet1[Location],
        Sheet1[Level],
        Sheet1[Category],
        Sheet1[Name],
        "qua", SUM ( Sheet1[Quantity] )
    )
VAR suf =
    FILTER ( su, [Category] = "Hours" )
RETURN
    IF (
        ISFILTERED ( Sheet1[Location] ),
        CALCULATE (
            COUNT ( Sheet1[Quantity] ),
            FILTER ( Sheet1, Sheet1[Category] = "Hours" && Sheet1[Quantity] > 1 )
        ),
        CALCULATE ( COUNTROWS ( suf ) )
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
cristianml
Post Prodigy
Post Prodigy

Hi @parry2k ,

 

In the following example I need a formula to count a total 2 intead of 5 :

 

1.jpg

In the example the result should be 2 ( one per "name")

Regards,

 

Hi @cristianml ,

 

To create a measure as below.

Measure = 
VAR su =
    SUMMARIZECOLUMNS (
        Sheet1[Location],
        Sheet1[Level],
        Sheet1[Category],
        Sheet1[Name],
        "qua", SUM ( Sheet1[Quantity] )
    )
VAR suf =
    FILTER ( su, [Category] = "Hours" )
RETURN
    IF (
        ISFILTERED ( Sheet1[Location] ),
        CALCULATE (
            COUNT ( Sheet1[Quantity] ),
            FILTER ( Sheet1, Sheet1[Category] = "Hours" && Sheet1[Quantity] > 1 )
        ),
        CALCULATE ( COUNTROWS ( suf ) )
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @v-frfei-msft ,

 

I just figured out..  I combined your measure with distinctcount and works perfect 🙂  

 

Headcount = CALCULATE(DISTINCTCOUNT('Resource Actual'[Name]),FILTER('Resource Actual','Resource Actual'[Category]="Hours" && 'Resource Actual'[Quantity]>8))

 

Thanks :)!!

 

Hi @v-frfei-msft ,

 

Thans for this,  is closer to what I need but how can I see 1 for each name in the column ( by the category line I choose, that in thi case is "Hours") ?  In the example how would be the measure to see 1 instead of 3 ?  i have many filters applied and I would like to see a headcount per "Level" and the number 1 per each name

 

Thanks

 

 

parry2k
Super User
Super User

@cristianml your question is not very clear> What you are trying to count? What you mean by duplicate? Can you explain  your logic again and example output based on the sample data you posted.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.