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
Alan_
Advocate II
Advocate II

countifs in powerBI

Hi i have an excel countifs i want to use in powerbi within a calculted column. 

 

In the equip column i have:

 

=COUNTIFS($L$2:[@[machine_serial_number]],[@[machine_serial_number]],$C$2:[@[SITE_NO]],[@[SITE_NO]])

 

 

SITE_NOEquip machine_serial_number
630106A10260200
63011005100101348
8951012011449547
89510895-05
6301BH1004191
6301K9091550
8951KY000961
89519803CL0208
89529803CL0208

 

What can I use to provide the same result in powerBI?

6 REPLIES 6
Phil_Seamark
Employee
Employee

Hi @Alan_,

 

So do you want a running total of how many times a machine_serial_number exists for any given site?

 

Do you have an index column or datetime column?

 

Otherwise it will be tricky to separate the bottom two rows.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Yes that's it and yes i have a date / time, the table is structured oldest to newest so the count should increase down the table. It's like the rank function but resets based on criteria, in this case the serial and site numbers

Hi @Alan_,

 

So can you please post your data with the datetime.  I can use this to split ties to give a better result.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

 

 

Capture.PNG

Ok here is a better excerpt. In this case the formula in "equip" is:

=COUNTIFS($D$2:[@Serial],[@Serial],$B$2:[@[SITE_NO]],[@[SITE_NO]])

Hi @Alan_,

Have your issue resloved according to @Phil_Seamark posted? It it does, please mark the reight reply as answer. If you doesn't, please feel free to ask.

Best Regards,
Angelia

Hi @Alan_

 

Please try adding this calculated column to your table.  You'll have to rename from Table2 to yours, and comment out the 3rd last line if you need the SITE_NOs to match

 

Equip = CALCULATE(
            COUNTROWS('Table2'),
            FILTER('Table2',
                'Table2'[Event] <= EARLIER('Table2'[Event])
                && 'Table2'[Serial] = EARLIER('Table2'[Serial])
                --&& 'Table2'[SITE_NO] = EARLIER('Table2'[SITE_NO])
                )
                )

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.