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
Anonymous
Not applicable

Sum values for last date in selection, grouped by store

Hi,

 

I need your help to sum the values for the last date in the selected months, at the level of each store.

 

1. I have a month slicer - where I have selected 3 months - Aug, Sep, Oct

 

Below is the table based on filters:

 

store_namesession_datetask_nameTotal
STORE 113-SepMS15
STORE 111-OctMS75
STORE 231-AugMS47
STORE 221-SepMS69
STORE 205-OctMS42
   248

 

From the above table I need to extract only the last session for each store, with the total, like below.

store_namesession_datetask_nameTotal
STORE 111-OctMS75
STORE 205-OctMS42
    

 

So far I have:

 

1. A measure to calculate the MaxVisit: 

MaxVisit =max(ExportData[session_date])

2. A measure to get the last date facings:

LastDateFacings =

VAR CurrentName = SELECTEDVALUE(ExportData[store_name])

VAR LastDatewithData = LASTNONBLANK(ExportData[session_date],
                                                                  SUM(ExportData[number_of_facings]))
 
RETURN
          CALCULATE(
                            SUM(ExportData[number_of_facings]),LastDatewithData,ExportData[store_name]=CurrentName)



Somehow it's working, it does filter, but only If in the table I have the store name on rows, otherwise it displays nothing.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Your measure won't work when there are multiple stores in the local filter context because SELECTEDVALUE(ExportData[store_name]) will return a blank when there isn't a single value.

 

One way around this is to iterate over each store individually like this:

SUMX ( VALUES ( ExportData[store_name] ), [LastDateFacings] )

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

Your measure won't work when there are multiple stores in the local filter context because SELECTEDVALUE(ExportData[store_name]) will return a blank when there isn't a single value.

 

One way around this is to iterate over each store individually like this:

SUMX ( VALUES ( ExportData[store_name] ), [LastDateFacings] )

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.