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
WilliamKaro
Regular Visitor

How do i find a maximum value based on 2 columns?

Hi There

 

I am trying to figure out how to pull out a calculation called 'based units' which would be the MAX of units non promo but it needs to be by EAN_item and MrktID and NOT period_key as i am trying to evaluate a consistant units sold week on week that wasn't on promotion. It has to stay consistant through every period. Below is an example of the data and wondered if anyone knows what query to use? I've tried CALCULATE MAX across ALL Periods but this wouldn't put product and mrkt into context. Any ideas on how i can do this? 

 

WilliamKaro_0-1702980071194.png

 

The end goal would to get to something like this (and if total units sold is less than base it would equal total units) with incremental units being (total units - incremental units) :

WilliamKaro_1-1702980146399.png

 

Many Thanks! 🙂

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @WilliamKaro ,

 

Based on the information you have provided, I can only reproduce part of your requirements, you can provide non-private details or pbix files to achieve your final goal. Depending on the first part of the information you provide, you can follow these steps:

 

1.Add a measure

 

Measure =

CALCULATE (

    MAX ( 'Table'[Units Non_Promo] ),

    FILTER (

        ALL ( 'Table' ),

        'Table'[EAN_Item] = SELECTEDVALUE ( 'Table'[EAN_Item] )

    )

)

 

 

Final output:

vyifanwmsft_0-1703057210683.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

1 REPLY 1
Anonymous
Not applicable

Hi @WilliamKaro ,

 

Based on the information you have provided, I can only reproduce part of your requirements, you can provide non-private details or pbix files to achieve your final goal. Depending on the first part of the information you provide, you can follow these steps:

 

1.Add a measure

 

Measure =

CALCULATE (

    MAX ( 'Table'[Units Non_Promo] ),

    FILTER (

        ALL ( 'Table' ),

        'Table'[EAN_Item] = SELECTEDVALUE ( 'Table'[EAN_Item] )

    )

)

 

 

Final output:

vyifanwmsft_0-1703057210683.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

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!

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.