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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Get the Max Value from SUM group

Hi, 

I am new in PBI, and I am trying to get something similar to this SQL query:


select b.[DescripcionBancos],SUM([ImporteDlls]),[IdDerivadoTipo]
from [dbo].[Fact_IndicadoresSIF] a
join [dev_fin].[sif_vDimBancos] b
on a.IdBanco=b.IdBanco
where [CalendarioID]=20180331
and [DescripcionBancos] in ('BBVA BANCOMER','HSBC','RABOBANK','SANTANDER')
AND Concepto='CCS'
Group by b.[DescripcionBancos],[IdDerivadoTipo]
order by 1,2

 

baxter2_nois102_0-1627866641019.png

 

Basically I am doing a SUM but I am getting the TOTAL and not the MAX(IdDerivadoTipo), I am using this Metric but I dont' know hot to adjust it in order to group the data and take the MAX (those values with 3):


PosicionDerivados_LineaLimite:=
CALCULATE(SUM(FactIndicadoresSIF[ImporteDlls])
,FactIndicadoresSIF[Indicador] IN {"Derivados","Ind. Derivados"}
,FactIndicadoresSIF[Concepto]="CCS")

This is the chart but it shoud have 20 in BBVA, HSBC is correct, RABOBANK should be 10 and Santander should be 16

baxter2_nois102_1-1627866802309.png

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Anonymous I would generally do something like:

PosicionDerivados_LineaLimite:=
  VAR __Table = 
    SUMMARIZE(
      FILTER(FactIndicadoresSIF, FactIndicadoresSIF[Indicador] IN {"Derivados","Ind. Derivados"} && FactIndicadoresSIF[Concepto]="CCS"),
      [IdDerivadoTipo],
      "__Sum",SUM(FactIndicadoresSIF[ImporteDlls])
    )
RETURN
  MAXX(__Table,__Sum)

 

If I understand your code. Basically, use SUMMARIZE, SUMMARIZECOLUMNS or GROUPBY to group your filtered rows by the specified colum and essentially add a sum as a column. Then use MAXX to find the MAX across that sum.


@ 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

1 REPLY 1
Greg_Deckler
Super User
Super User

@Anonymous I would generally do something like:

PosicionDerivados_LineaLimite:=
  VAR __Table = 
    SUMMARIZE(
      FILTER(FactIndicadoresSIF, FactIndicadoresSIF[Indicador] IN {"Derivados","Ind. Derivados"} && FactIndicadoresSIF[Concepto]="CCS"),
      [IdDerivadoTipo],
      "__Sum",SUM(FactIndicadoresSIF[ImporteDlls])
    )
RETURN
  MAXX(__Table,__Sum)

 

If I understand your code. Basically, use SUMMARIZE, SUMMARIZECOLUMNS or GROUPBY to group your filtered rows by the specified colum and essentially add a sum as a column. Then use MAXX to find the MAX across that sum.


@ 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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.