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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PowerBiDax
Regular Visitor

Calculate Group by 2 others columns

Hello,

I need to create a measure using DAX that has the sum of the qty, I should take the max date of the table that is between two other dates (Date Slicer) based on the column name, For exemple if the selected date of the slicer is between  24/6/2020 and 20/3/2021

PowerBiDax_0-1673977482296.png

the result should be 

PowerBiDax_1-1673977732813.png

Thank you.

 

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1673978970698.png

 

Jihwan_Kim_1-1673979877409.png

 

 

Expected result Date: =
CALCULATE (
    SELECTEDVALUE ( 'Calendar'[Date] ),
    INDEX (
        1,
        SUMMARIZE ( ALLSELECTED ( Data ), 'Name'[Name], 'Calendar'[Date], Data[Qty] ),
        ORDERBY ( 'Calendar'[Date], DESC, Data[Qty], DESC ),
        KEEP,
        PARTITIONBY ( 'Name'[Name] )
    )
)

 

Expected result Qty: = 
CALCULATE (
    SUM(Data[Qty]),
    INDEX (
        1,
        SUMMARIZE ( ALLSELECTED ( Data ), 'Name'[Name], 'Calendar'[Date], Data[Qty] ),
        ORDERBY ( 'Calendar'[Date], DESC, Data[Qty], DESC ),
        KEEP,
        PARTITIONBY ( 'Name'[Name] )
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you a lot for your help, but I don't know why it's not working for me 

PowerBiDax_1-1673980675623.png

 

 

Hi,

just in case, please check the version of the power bi desktop.

 

December 2022

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Now the pbix works, but this is not what I have to get, when selecting the date(in the slicer) I need to get  the qty of the max date of the name that is between the selected date, for exp for B I need to take the Qty=50(it correspond to the max date (Sat, 30 Jan 2021 00:00:00 between the selected date of the slicer) 

PowerBiDax_0-1674042049086.png

The Expected result date is correct date, now I have to take the qty that corresponds to it. 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors