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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.