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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Tokkerashid
Frequent Visitor

How to summarize /group by/ count measure values

Hi all,

 

I have trouble with grouping measure values. I have table events with columns: Product,  measure Price1 (p1) and then created measure Price2 (p2) from p1, and then Differece between these two prices (Diff), also a measure:

Product

 

         p1

(measure)

                  p2

          (measure) 

           Diff

         (p1-p2) 

a1     5,525                  5,515               0,010
b2     5,535                  5,515               0,020
b4      5,525                  5,505               0,020
b6      5,520                  5,510               0,010
c3      5,520                  5,500               0,020
c5      5,525                  5,520               0,005
a5      5,530                  5,510               0,020
d2      5,505                  5,500               0,005
d4      5,525                  5,520               0,005

 

Now I want to group (count) these differences in this way, Value 0,005 is shown 3 times in table, 0,010 is shown 2 times, etc.:

DiffTotal
0,005     3
0,010     2
0,020     4

 

but it doesn't allow me to group measure valus.

(The CALCULATE  function cannot be used in an expression argument for the GROUPBY() function.)

Any ideas how to do this?

 

Thanks!

4 REPLIES 4
Tokkerashid
Frequent Visitor

I resolved this issue in a way that I created new table from existing one with a Diff as a column. And then regular DISTINCTCOUNT works. 

FreemanZ
Super User
Super User

hi @Tokkerashid 

following your description, you may try to create a measure like this:

 

Measure = 
VAR _table1 = 
ADDCOLUMNS(
    SUMMRIZE(
        Products,
        Products[Product],
        Products[P1]
    ),
    "p2", [p2]
)
VAR _table2 = 
ADDCOLUMNS(
    _table1,
    "Diff",
    Products[p1]-[p2]
)
VAR _diff = SELECTEDVALUE(SegmentTable[Diff])
RETURN
COUNTROWS(FILTER(_table2), [Diff]= _diff )

 

The measure is supposed to plot a table visual with the SegmentTable[Diff] column. The Products table and SegmentTable are unrelated.

if case of issue, please consider providing some sample data.

Hi @FreemanZ ,

 

Unfortunatelly it is not working. Also p1 is a measure, and it is all one same table (Events).
it is not allow me to add in selectedvalue a measure

Tokkerashid_0-1674133572175.png

 

 

johnt75
Super User
Super User

Have a look at the dynamic segmentation DAX pattern.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.