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
eomedes
Regular Visitor

Counting grouped occurrences

Hello, I make a summary of the situation.
I have a dimension table of calendar and another one of hours, and on the other hand, two tables of facts both related to those dimension tables.

 

eomedes_0-1652086605194.png

 

eomedes_1-1652086627537.png

 


Then, I make a measurement, where if the value A minus B is positive, 1, otherwise 0.

 

Difference A-B = IF(SUM('TABLE A'[Value Table A])-SUM('TABLE B'[Value Table B])>0,1,0)

 

Then, in a matrix, as rows I put the days of the week, as columns, the hours, and as value, the measurement made.

 

eomedes_2-1652086686316.png

 

So far, so good.

The problem is that I want to have in a card, a counter of occurrences in which the value of the measure is 1. I want the sum of all the yellow cells.

eomedes_3-1652086720745.png

 


I have tried to use COUNTAX, but I cannot group by time and date because they come from two independent tables (it has to be).

Thanks everyone!!

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@eomedes try this:

 

 

Measure = 
COUNTROWS(
    FILTER(
        ADDCOLUMNS(
            CROSSJOIN(
                VALUES('Days'[Date]),
                VALUES('Hour'[Hour])
            ),
            "@Test", [Difference A-B]
        ),
        [@Test] = 1
    )
) 

 

 

 Or this (depandant on your business case):

 

Measure = 
COUNTROWS(
    FILTER(
        ADDCOLUMNS(
            CROSSJOIN(
                VALUES('Days'[Day Of Week]),
                VALUES('Hour'[Hour])
            ),
            "@Test", [Difference A-B]
        ),
        [@Test] = 1
    )
) 

 

 

In case it answered your question, please accept it as a solution to help the other members find it more quickly. Appreciate Your Kudos 💪
Showcase Report – Contoso By SpartaBI 
Website Linkedin Facebook 
This is SpartaBI!

View solution in original post

1 REPLY 1
SpartaBI
Community Champion
Community Champion

@eomedes try this:

 

 

Measure = 
COUNTROWS(
    FILTER(
        ADDCOLUMNS(
            CROSSJOIN(
                VALUES('Days'[Date]),
                VALUES('Hour'[Hour])
            ),
            "@Test", [Difference A-B]
        ),
        [@Test] = 1
    )
) 

 

 

 Or this (depandant on your business case):

 

Measure = 
COUNTROWS(
    FILTER(
        ADDCOLUMNS(
            CROSSJOIN(
                VALUES('Days'[Day Of Week]),
                VALUES('Hour'[Hour])
            ),
            "@Test", [Difference A-B]
        ),
        [@Test] = 1
    )
) 

 

 

In case it answered your question, please accept it as a solution to help the other members find it more quickly. Appreciate Your Kudos 💪
Showcase Report – Contoso By SpartaBI 
Website Linkedin Facebook 
This is SpartaBI!

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.

Top Solution Authors