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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
SureshPydi1
Frequent Visitor

Need Help on Sum of Distinct Columns

Hi Team,

I need help on Distinct Columns in a table using Measure.

 

Here is my Query.  My Table is as follows. We need to get the Distinact Values from all the rows of a table and get Some of one column.

 

Based on all Columns we need to get the Distnict Values and get the Sum of FS_Amount column value

SureshPydi1_0-1676490275274.png

 

Here in the above image i need to get the Distinct rows based on Supplier, feedback Amount,  Category, Street Addres, City, State, Lattitute, Langitute. (Ie. there might be chance that all the Columns are same except one column. in that case we will consider it as Distinct. We need to eliminate all the column values are same.)


Once we get the Disctinict rwos, need to get the count of the Feedstock amount based on the results.

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@SureshPydi1 So like this?

Measure = 
  VAR __Table = 
    SUMMARIZE(
      'Table',
      [Supplier], [Category], [Street Address], [City], [State], [Latitude], [Longitude],
      "__FSAmount", SUM([Feedstock Amount])
    )
  VAR __Result = COUNTROWS(DISTINCT(__Table))
RETURN
  __Result

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

SureshPydi1
Frequent Visitor

Hi @Greg_Deckler ,

 

Thanks Somuch for your help. I have changed the logic and i am able to achive the requirement.

 

Here is the updated query

In the code i have updated the filter and updated the Sum to Max to get the Sum of the column.

Measure=
VAR __Table =
Filter(SUMMARIZE(
'SupplierByFarmRadius',
[Supplier],[Category],[StreetAddress],[City],[State],[AddressTypeID],
"__FSAmount", MAX([FS_Amount])
),SupplierByFarmRadius[AddressTypeID]<>1)
VAR __Result = SumX(DISTINCT(__Table),[__FSAmount])
RETURN
__Result

 

View solution in original post

2 REPLIES 2
SureshPydi1
Frequent Visitor

Hi @Greg_Deckler ,

 

Thanks Somuch for your help. I have changed the logic and i am able to achive the requirement.

 

Here is the updated query

In the code i have updated the filter and updated the Sum to Max to get the Sum of the column.

Measure=
VAR __Table =
Filter(SUMMARIZE(
'SupplierByFarmRadius',
[Supplier],[Category],[StreetAddress],[City],[State],[AddressTypeID],
"__FSAmount", MAX([FS_Amount])
),SupplierByFarmRadius[AddressTypeID]<>1)
VAR __Result = SumX(DISTINCT(__Table),[__FSAmount])
RETURN
__Result

 

Greg_Deckler
Super User
Super User

@SureshPydi1 So like this?

Measure = 
  VAR __Table = 
    SUMMARIZE(
      'Table',
      [Supplier], [Category], [Street Address], [City], [State], [Latitude], [Longitude],
      "__FSAmount", SUM([Feedstock Amount])
    )
  VAR __Result = COUNTROWS(DISTINCT(__Table))
RETURN
  __Result

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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