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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
ab00sa7i
Frequent Visitor

Help with DAX

Hi, I have a data looks like this:

image001.jpg

 I would like to create a three new columns (like shown on the right of the picture),

 

the first column should contain the first reason of error (type of error according to importance, should be number 3 as it is the most important).

 

Second column should contains the second reason of error ( should be number 2)

 

And thrid column should contains the third reason.

 

https://docs.google.com/spreadsheets/u/0/d/1Irl4Pp3o8BXTPxwRm1tuT5hdGwO2U-OP/htmlview

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ab00sa7i ,

I create the table as you mentioned.

vyilongmsft_0-1723692870888.png

Then I think you can create three calculated columns.

reason1 = 
VAR _max =
    CALCULATE (
        MAX ( 'Table'[number of repeted error with important degree] ),
        ALLEXCEPT ( 'Table', 'Table'[id] )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[error type] ),
        ALLSELECTED ( 'Table' ),
        'Table'[number of repeted error with important degree] = _max
    )
reason2 = 
VAR _max =
    CALCULATE (
        MAX ( 'Table'[number of repeted error with important degree] ),
        ALLEXCEPT ( 'Table', 'Table'[id] )
    )
VAR _next =
    CALCULATE (
        MAX ( 'Table'[number of repeted error with important degree] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[id] = EARLIER ( 'Table'[id] )
                && 'Table'[number of repeted error with important degree] < _max
        )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[error type] ),
        ALLSELECTED ( 'Table' ),
        'Table'[number of repeted error with important degree] = _next
    )
reason3 = 
VAR _min =
    CALCULATE (
        MIN ( 'Table'[number of repeted error with important degree] ),
        ALLEXCEPT ( 'Table', 'Table'[id] )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[error type] ),
        ALLSELECTED ( 'Table' ),
        'Table'[number of repeted error with important degree] = _min
    )

Finally you will get what you want.

vyilongmsft_1-1723692983797.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @ab00sa7i ,

I create the table as you mentioned.

vyilongmsft_0-1723692870888.png

Then I think you can create three calculated columns.

reason1 = 
VAR _max =
    CALCULATE (
        MAX ( 'Table'[number of repeted error with important degree] ),
        ALLEXCEPT ( 'Table', 'Table'[id] )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[error type] ),
        ALLSELECTED ( 'Table' ),
        'Table'[number of repeted error with important degree] = _max
    )
reason2 = 
VAR _max =
    CALCULATE (
        MAX ( 'Table'[number of repeted error with important degree] ),
        ALLEXCEPT ( 'Table', 'Table'[id] )
    )
VAR _next =
    CALCULATE (
        MAX ( 'Table'[number of repeted error with important degree] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[id] = EARLIER ( 'Table'[id] )
                && 'Table'[number of repeted error with important degree] < _max
        )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[error type] ),
        ALLSELECTED ( 'Table' ),
        'Table'[number of repeted error with important degree] = _next
    )
reason3 = 
VAR _min =
    CALCULATE (
        MIN ( 'Table'[number of repeted error with important degree] ),
        ALLEXCEPT ( 'Table', 'Table'[id] )
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[error type] ),
        ALLSELECTED ( 'Table' ),
        'Table'[number of repeted error with important degree] = _min
    )

Finally you will get what you want.

vyilongmsft_1-1723692983797.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.