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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MrSam
Frequent Visitor

DAX Column/measure to get No of occurrences based on conditions

Hi Community,

 

Need your expert help getting the 1 in the result column when either of Model output value 1

My ultimate goal is to show No of occurrences in a matrix visual.

 

IDNameModelModel DateModel OutputResult
44444PanA31-Dec-2200
44444PanB31-Dec-2200
44444PanA31-Mar-2300
44444PanB31-Mar-2300
55555LemoineA31-Dec-2211
55555LemoineB31-Dec-2201
55555LemoineA31-Mar-2301
55555LemoineB31-Mar-2301
66666PaulA31-Dec-2211
66666PaulB31-Dec-2211
66666PaulA31-Mar-2301
66666PaulB31-Mar-2301
77777NancyA31-Dec-2212
77777NancyB31-Dec-2212
77777NancyA31-Mar-2312
77777NancyB31-Mar-2302
88888PeterA31-Dec-2212
88888PeterB31-Dec-2212
88888PeterA31-Mar-2312
88888PeterB31-Mar-2312

 

My ultimate target is to get below matrix visual,

MrSam_0-1683520642124.png

Thank you

2 ACCEPTED SOLUTIONS

hi @tamerj1 

I was trying hard to add the expected calculated column. do you have some good suggestion?

 

What i succeed so far is very cumbersome:

Result2 = 
SUMX(
    FILTER(
        ADDCOLUMNS(
            SUMMARIZE(
                data,
                data[ID],
                data[Model Date]
            ),
            "Output",
            MAXX(
                FILTER(
                    data,
                    data[ID]=EARLIER(data[ID])
                        &&data[Model Date]=EARLIER(data[Model Date])
                ),
                data[Model Output]
            )
        ),
        data[ID]=EARLIER(data[ID])
    ),
    [Output]
)

 

FreemanZ_0-1683527799082.png

tried to simplify the code with CALCULATE, but with no success. 

View solution in original post

Hi @FreemanZ 

My understanding that perhaps @MrSam have some kind of live connection and cannot create calculated columns. This is why I proposed a measure. @MrSam please let me know if I misunderstood the requirement.

3.png

ResultMeasure = 
SUMX (
    VALUES ( 'Table'[Model Date] ),
    CALCULATE ( MAX ( 'Table'[Model Output] ) )
)

 

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

Hi @MrSam 

please try

ResultMeasure =
SUMX (
VALUES ( 'Table'[Model Date] ),
CALCULATE ( MAX ( 'Table'[Model Output] ) )
)

 

the Number of Occurances that is present in your expected matrix visual would be the total column at the left of the matrix 

hi @tamerj1 

I was trying hard to add the expected calculated column. do you have some good suggestion?

 

What i succeed so far is very cumbersome:

Result2 = 
SUMX(
    FILTER(
        ADDCOLUMNS(
            SUMMARIZE(
                data,
                data[ID],
                data[Model Date]
            ),
            "Output",
            MAXX(
                FILTER(
                    data,
                    data[ID]=EARLIER(data[ID])
                        &&data[Model Date]=EARLIER(data[Model Date])
                ),
                data[Model Output]
            )
        ),
        data[ID]=EARLIER(data[ID])
    ),
    [Output]
)

 

FreemanZ_0-1683527799082.png

tried to simplify the code with CALCULATE, but with no success. 

Hi @FreemanZ 

My understanding that perhaps @MrSam have some kind of live connection and cannot create calculated columns. This is why I proposed a measure. @MrSam please let me know if I misunderstood the requirement.

3.png

ResultMeasure = 
SUMX (
    VALUES ( 'Table'[Model Date] ),
    CALCULATE ( MAX ( 'Table'[Model Output] ) )
)

 

MrSam
Frequent Visitor

In this case I do not have a live connection. Thank you and this solution works. However, I have a few other fields adding to the Matrix visual, therefore, having the Total column in the matrix visual was not the best, so I will select @FreemanZ solution for this particular scenario.

 @MrSam 

You can also try the following calculated column

1.png

Result = 
SUMX (
    SUMMARIZE ( 
        CALCULATETABLE ( 
            'Table',
            ALLEXCEPT ( 'Table', 'Table'[ID] )
        ),
        'Table'[Model Date],
        "@Value", MAX ( 'Table'[Model Output] )
    ),
    [@Value]
)

hi @tamerj1 

that is what i was striving for. thank you.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.