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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
TomSinAA
Helper III
Helper III

measure to group values

Is it possible to create measures that display the unique value for a column in a table that has multiple repeating rows with the same values in the column and the measure uses another column to group by.

 

If the data looks like this: 

StateColorIDPKDescriptionA PtsB PtsMade Pts
ReadyYellow3ABX-45Walking732
ReadyYellow3ABX-45Walking731
ReadyYellow3ABX-45Walking73NULL
ReadyYellow3ABX-45Walking73NULL
ReadyYellow3ABX-45Walking73NULL
ReadyBlue3ABX-46Running94NULL
ReadyBlue3ABX-46Running94NULL
ReadyBlue3ABX-46Running941
ReadyBlue3ABX-46Running94NULL
ReadyBlue3ABX-46Running94NULL

 

 

I want to be able create a measure for A pts and B pts columns that display the data like this:

StateColorIDPKDescriptionA PtsB PtsMade Pts
ReadyYellow3ABX-45Walking733
ReadyBlue3ABX-46Running941

 

So A pts and B pts columns are grouped by Description when rolled up into the summary table, but Made Pts column sums the total by Description.

 

Then another table that displays the overall totals like this:

StateA PtsB PtsMade Pts
Ready1674
1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @TomSinAA 

You can try the following mwasures

A =
VAR A =
    SUMMARIZE ( 'Table', [State], [Color], [PK], "a_min", MIN ( 'Table'[A Pts] ) )
RETURN
    SUMX (
        FILTER (
            A,
            [State]
                IN VALUES ( 'Table'[State] )
                    && [Color]
                        IN VALUES ( 'Table'[Color] )
                            && [PK] IN VALUES ( 'Table'[PK] )
        ),
        [a_min]
    )
B =
VAR A =
    SUMMARIZE ( 'Table', [State], [Color], [PK], "b_min", MIN ( 'Table'[b Pts] ) )
RETURN
    SUMX (
        FILTER (
            A,
            [State]
                IN VALUES ( 'Table'[State] )
                    && [Color]
                        IN VALUES ( 'Table'[Color] )
                            && [PK] IN VALUES ( 'Table'[PK] )
        ),
        [b_min]
    )
Mode =
VAR A =
    ADDCOLUMNS (
        'Table',
        "Mode", IF ( [Made Pts] <> "NULL", INT ( [Made Pts] ), 0 )
    )
VAR b =
    SUMMARIZE (
        A,
        [State],
        [Color],
        [PK],
        "Sum",
            SUMX (
                FILTER (
                    a,
                    [State]
                        IN VALUES ( 'Table'[State] )
                            && [Color]
                                IN VALUES ( 'Table'[Color] )
                                    && [PK] IN VALUES ( 'Table'[PK] )
                ),
                [Mode]
            )
    )
RETURN
    SUMX (
        FILTER (
            b,
            [State]
                IN VALUES ( 'Table'[State] )
                    && [Color]
                        IN VALUES ( 'Table'[Color] )
                            && [PK] IN VALUES ( 'Table'[PK] )
        ),
        [Sum]
    )

vxinruzhumsft_1-1693810790430.png

 

Best Regards!

Yolo Zhu

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

9 REPLIES 9
v-xinruzhu-msft
Community Support
Community Support

Hi @TomSinAA 

You can try the following mwasures

A =
VAR A =
    SUMMARIZE ( 'Table', [State], [Color], [PK], "a_min", MIN ( 'Table'[A Pts] ) )
RETURN
    SUMX (
        FILTER (
            A,
            [State]
                IN VALUES ( 'Table'[State] )
                    && [Color]
                        IN VALUES ( 'Table'[Color] )
                            && [PK] IN VALUES ( 'Table'[PK] )
        ),
        [a_min]
    )
B =
VAR A =
    SUMMARIZE ( 'Table', [State], [Color], [PK], "b_min", MIN ( 'Table'[b Pts] ) )
RETURN
    SUMX (
        FILTER (
            A,
            [State]
                IN VALUES ( 'Table'[State] )
                    && [Color]
                        IN VALUES ( 'Table'[Color] )
                            && [PK] IN VALUES ( 'Table'[PK] )
        ),
        [b_min]
    )
Mode =
VAR A =
    ADDCOLUMNS (
        'Table',
        "Mode", IF ( [Made Pts] <> "NULL", INT ( [Made Pts] ), 0 )
    )
VAR b =
    SUMMARIZE (
        A,
        [State],
        [Color],
        [PK],
        "Sum",
            SUMX (
                FILTER (
                    a,
                    [State]
                        IN VALUES ( 'Table'[State] )
                            && [Color]
                                IN VALUES ( 'Table'[Color] )
                                    && [PK] IN VALUES ( 'Table'[PK] )
                ),
                [Mode]
            )
    )
RETURN
    SUMX (
        FILTER (
            b,
            [State]
                IN VALUES ( 'Table'[State] )
                    && [Color]
                        IN VALUES ( 'Table'[Color] )
                            && [PK] IN VALUES ( 'Table'[PK] )
        ),
        [Sum]
    )

vxinruzhumsft_1-1693810790430.png

 

Best Regards!

Yolo Zhu

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

parry2k
Super User
Super User

parry2k_0-1693616496835.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@TomSinAA I think you need this measure , you can replicate it for others as well:

 

Measure A Pts = 
SUMX ( 
    SUMMARIZE ( 
        MyTable, 
        MyTable[State], 
        MyTable[Color], 
        MyTable[ID], 
        MyTable[PK], 
        MyTable[Description], 
        "@Min", MIN ( MyTable[A Pts] ) 
    ), 
    [@Min] 
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@TomSinAA try something like this:

 

 

M1 = SUMX ( YourTable, CALCULATE ( min(Data[A Pts] ) ) )

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

That did not work.  It still shows 80

 

TomSinAA_0-1693615511873.png

 

Ashish_Mathur
Super User
Super User

Hi,

Drag the first 4 columns to a Table visual and write these measures

M1 = min(Data[A Pts])

M2 = min(Data[B Pts])

M3 = sum(Data[Made Pts])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That works for the body of the first visual titled: Summary by State, ID, Color, Description.  But the total at the bottom is not correct.  It should be 16 for A pts and 7 for B Pts.  It does not work for the Summary by State visual.

 

TomSinAA_0-1693570316589.png

 

  

 

 

Hi,

Try these measures

A pt = MIN(Data[A Pts])
B pt = MIN(Data[B Pts])
A points = if(HASONEVALUE(Data[Color]),[A pt],SUMX(VALUES(Data[Color]),[A pt]))
B points = if(HASONEVALUE(Data[Color]),[B pt],SUMX(VALUES(Data[Color]),[B pt]))
Made points = SUM(Data[Made Pts])

Hope this helps.

Ashish_Mathur_0-1693632470954.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Ok, here is a visual using the same structured data.  

TomSinAA_1-1693603064886.png

 

I am using this measure as the:

1.ReqBoardEpicEstReqPts = CONVERT(CALCULATE(Max('pbi Issue'[ReqBoardEpicEstimatedRequirementsPoints]),FILTER('pbi Issue',ISBLANK([IssueEpicLink])=True)),INTEGER)
 
Why is the Mini Epic rown and grand Total diplaying as 50.  I want them to add the values for the individual Req rows. 

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Top Solution Authors