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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
masch112
Regular Visitor

Counting rows in a visual (table) with one measure and two dimensions

Dear community,

 

I am using If-functions to check my data for unusual values (like negative revenue).
I would like to count rows in a table that displays such an if-function.


The if-function looks like this


Negative Net Sales Total=

IF([KPI_ Net Sales Total]<0;
[KPI_Net Sales Total])

 

and the corresponding KPI like this:


KPI_Net Sales Total =
CALCULATE(SUM(Totals_All[GC Wert invers]);
DATESYTD('Datum'[Datum]);
IncomeStatement[Ebene8] = "Net sales total")

The problem I am facing is that I use two additional dimensions in the table, company and account name.
In order to count the rows in this table, I somehow have to aggregate/group/summarize the measure by company and account name. If I don't aggregate the measure, no value is returned as the revenue IN TOTAL is not negative.

MeasureAndCount.JPG

I've managed to achieve this in QlikView before, this is the expected output:


MeasureAndCount.JPG

 

In QV, in order to count the rows, you would distinctcount the company & account name, by aggregating them with this expression:
Count(Distinct aggr(IF($(KPI_Net Sales Total)<0 , [Name Financial Statement Item] &[Company Name]), [Company Name], [Name Financial Statement Item])) 

Does anyone know how to achieve this? I think I have to use either groupby or summarize in DAX but I am not yet familiar enough with the syntax.

Thank you very much in advance!

Best regards,
Mats

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

@masch112,

 

In order to count the rows in this table, I somehow have to aggregate/group/summarize the measure by company and account name.

You could use ALLEXCEPT function to count the row group by Company. This function removes all context filters in the table except filters that have been applied to the specified columns. Smaple DAX for you reference.
Count = CALCULATE(COUNT(Table3[Value]),FILTER(ALLEXCEPT(Table3,Table3[Group]),Table3[Value]<0))

Capture.PNG

 

If this is not what you want, please elaborate your requirement, so that we can make further analysis.

 

Regards,

Charlie Liao

View solution in original post

1 REPLY 1
v-caliao-msft
Microsoft Employee
Microsoft Employee

@masch112,

 

In order to count the rows in this table, I somehow have to aggregate/group/summarize the measure by company and account name.

You could use ALLEXCEPT function to count the row group by Company. This function removes all context filters in the table except filters that have been applied to the specified columns. Smaple DAX for you reference.
Count = CALCULATE(COUNT(Table3[Value]),FILTER(ALLEXCEPT(Table3,Table3[Group]),Table3[Value]<0))

Capture.PNG

 

If this is not what you want, please elaborate your requirement, so that we can make further analysis.

 

Regards,

Charlie Liao

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.