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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Paulien1989
Advocate II
Advocate II

I need to group rows and exclude rows from a measure: please help

Hi everyone, I have the following data (with abstract ficticious data) from a log book;

 

 

I want 2 things:

 

1. I want to add a group to each row specifying what group that Dimension belongs in, based on its last status; but only when the last status is 2 or 3! So when the last status is 2, the entire dimension should be grouped as "2" on every row. If the last status is 4, then Group should be blank.

 

2. Time 3 is basically AVERAGEX(Time1-Time2). The total average substracts Time2 from Time1 and then divides it by the number of rows, even by a row that has 0. I want to create a measure that results in the total average of (17,5+6+0)/2=11,75 or (2+0)/1=2 (example for dimensions A and B).

 

Please advise.

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Paulien1989

 

You may add an index column in query editor first. Then you may get the group and Time3_Total with below measures. Here is the sample file for your reference.

1.

LastIndex = CALCULATE(MAX(Table1[Index]),ALLEXCEPT(Table1,Table1[Dimension]))
LastStatus =
CALCULATE (
    MAX ( Table1[Status] ),
    FILTER ( ALLEXCEPT ( Table1, Table1[Dimension] ), Table1[Index] = [LastIndex] )
)
Group = IF([LastStatus]=3||[LastStatus]=2,[LastStatus])

2.

Time3 = CALCULATE(SUM(Table1[Time1])-SUM(Table1[Time2]))
Count =
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER ( ALLEXCEPT ( Table1, Table1[Dimension] ), [Time3] <> 0 )
)
Time3_Total =
IF ( HASONEFILTER ( Table1[Time1] ), [Time3], [Time3] / [Count] )

 

Regards,

Cherie

 

 

 

 

Community Support Team _ Cherie Chen
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
v-cherch-msft
Employee
Employee

Hi @Paulien1989

 

You may add an index column in query editor first. Then you may get the group and Time3_Total with below measures. Here is the sample file for your reference.

1.

LastIndex = CALCULATE(MAX(Table1[Index]),ALLEXCEPT(Table1,Table1[Dimension]))
LastStatus =
CALCULATE (
    MAX ( Table1[Status] ),
    FILTER ( ALLEXCEPT ( Table1, Table1[Dimension] ), Table1[Index] = [LastIndex] )
)
Group = IF([LastStatus]=3||[LastStatus]=2,[LastStatus])

2.

Time3 = CALCULATE(SUM(Table1[Time1])-SUM(Table1[Time2]))
Count =
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER ( ALLEXCEPT ( Table1, Table1[Dimension] ), [Time3] <> 0 )
)
Time3_Total =
IF ( HASONEFILTER ( Table1[Time1] ), [Time3], [Time3] / [Count] )

 

Regards,

Cherie

 

 

 

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.