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
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
Employee
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
Employee
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
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.