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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
dannyh246
Regular Visitor

Multiple Grouping & Sorting With Slicer

I have a fact table called FactAccumulation, which contains appox 500million records.

I have a dimension table called dimZone with about 50 records. 

 

Both are defined as follows. 

 

 

[FactAccumulation]

 

[Zone Key] [int] 
[Event Id] [int]
[Year] [int]
[Loss Usd] [decimal]

[DimZone]

[Zone Key] [int] 

[Zone Name] [VARCHAR

 

 

I want to be able to pick from a drop down (slicer) any number of Zones. Once i have the Zones selected, i want to 

 

1. Group the fact table on Zone & Year. (and summing up the Loss usd)

2. With the dataset from step 1, for each Zone Year pick the MAX loss value.

3. From the datatset in step 2 (Zone, Year, Max loss values), i want to partition by Zone order by Loss value descending and have row number appended.

 

In SQL it's fairly easy...something like this..

 

SELECT ROW_NUMBER() OVER(PARTITION BY occ.ZoneId ORDER BY occ.NetLossUsd DESC) AS RowNumber
             ,occ.[Year]
             ,occ.[ZoneId]
             ,occ.[NetLossUsd]
FROM
(
           SELECT e.[ZoneId]
                       ,e.[Year]
                       ,MAX(e.[NetLossUsd]) AS NetLossOurShareUsd
           FROM
            (
                   SELECT a.[EventId]
                               ,a.[ZoneId]
                               ,a.[Year]
                              ,SUM(a.[NetLossUsd]) AS NetLossUsd
                   FROM FactAccumulation a
                   GROUP BY a.[EventId]
                                     ,a.[AccumulationPerilId]
                                     ,a.[Year]
            ) e
            GROUP BY e.[ZoneId]
                             ,e.[Year]
            ) occ

 

How would i do this in PowrBi / DAX?

 

Any help would be much appreciated!!

 

Thanks

 

 

 

 

1 REPLY 1
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @dannyh246,

 

Please check out the demo here

1. Create a calculated table as MiddleTable.

MiddleTable =
SUMMARIZE (
    'FactAccumulation',
    DimZone[Zone Key],
    FactAccumulation[Event ID],
    FactAccumulation[Year],
    "Total", SUM ( FactAccumulation[Loss USD] )
)

2. Create a measure for row numbers.

RowNumEqually =
RANKX (
    ALL ( 'MiddleTable'[Year] ),
    CALCULATE ( MAX ( 'MiddleTable'[Total] ) )
)

3. Create a table visual. The choose calculation type Maximum for column "Total".

Multiple_Grouping_Sorting_With_Slicer

 

 

Best Regards,

Dale

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.