March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
Hi, using the table below, I need a measure showing me the Top1 Location with the most "Medical Concerns" between 02/08/2024 = 01/11/2024 and the count, please = Edinburgh, 4.
Again I need this as a measure not just the visual filters, please.
Incident Type | Location | Date | Financial Quarter |
Missing person | Glasgow | 02/08/2024 | Q2 |
Missing person | Glasgow | 02/08/2024 | Q2 |
Medical concern | Glasgow | 01/11/2024 | Q3 |
Missing person | Glasgow | 01/11/2024 | Q3 |
Missing person | Glasgow | 01/11/2024 | Q3 |
Medical concern | Edinburgh | 02/08/2024 | Q2 |
Medical concern | Edinburgh | 02/08/2024 | Q2 |
Missing Person | Edinburgh | 02/08/2024 | Q2 |
Medical concern | Edinburgh | 01/11/2024 | Q3 |
Medical concern | Edinburgh | 01/11/2024 | Q3 |
Aggression | Manchester | 02/08/2024 | Q2 |
Aggression | Manchester | 02/08/2024 | Q2 |
Aggression | Manchester | 01/11/2024 | Q3 |
Aggression | Manchester | 01/11/2024 | Q3 |
Medical concern | Manchester | 01/11/2024 | Q3 |
Thanks for your help.
Solved! Go to Solution.
Hi @RichOB ,
bhanu_gautam and Kedar have provided effective methods to obtain both the location and the top 1 count. You can make a slight adjustment to the measure below to include only the location:
Location with Top 1 Count =
VAR _tab =
SUMMARIZE (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Incident Type] = "Medical concern" ),
'Table'[Location],
"@Count", COUNT ( 'Table'[Incident Type] )
)
VAR _tab2 =
TOPN ( 1, _tab, [@Count], DESC )
RETURN
CONCATENATEX( _tab2, [Location],", " ,[Location],ASC)
Best Regards
You can create a DAX measure to find the top location with the most "Medical Concerns" in the given date range by combining several functions, such as CALCULATE, FILTER, and TOPN.
Here's a DAX measure that should help you achieve your goal:
Top1 Location with Medical Concerns = VAR StartDate = DATE(2024, 8, 2) VAR EndDate = DATE(2024, 11, 1) VAR FilteredTable = FILTER ( YourTableName, [Incident Type] = "Medical concern" && [Date] >= StartDate && [Date] <= EndDate ) VAR GroupedCount = SUMMARIZE ( FilteredTable, YourTableName[Location], "MedicalConcernsCount", COUNTROWS ( FilteredTable ) ) VAR TopLocation = TOPN ( 1, GroupedCount, [MedicalConcernsCount], DESC ) RETURN IF ( COUNTROWS ( TopLocation ) > 0, CONCATENATEX ( TopLocation, YourTableName[Location] & ", " & [MedicalConcernsCount], ", " ), "No data" )
Define Start and End Dates:
FilteredTable:
GroupedCount:
TopLocation:
RETURN:
This measure should give you the location with the most medical concerns within the given time frame, along with the count.
Top1LocationMedicalConcerns =
VAR FilteredData =
FILTER(
'Table',
'Table'[Incident Type] = "Medical concern" &&
'Table'[Date] >= DATE(2024, 8, 2) &&
'Table'[Date] <= DATE(2024, 11, 1)
)
VAR Summary =
SUMMARIZE(
FilteredData,
'Table'[Location],
"MedicalConcernsCount", COUNTROWS(FilteredData)
)
VAR TopLocation =
TOPN(1, Summary, [MedicalConcernsCount], DESC)
RETURN
CONCATENATEX(TopLocation, 'Table'[Location], ", ") & ", " &
MAXX(TopLocation, [MedicalConcernsCount])
In your case, it will return Edinburgh, 4.
💌 If this helped, a Kudos 👍 or Solution mark ✅ would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
@RichOB ,To create a measure in Power BI that shows the top location with the most "Medical Concerns" between 02/08/2024 and 01/11/2024,
Top1LocationMedicalConcerns =
VAR FilteredTable =
FILTER(
'Table',
'Table'[Incident Type] = "Medical concern" &&
'Table'[Date] >= DATE(2024, 8, 2) &&
'Table'[Date] <= DATE(2024, 11, 1)
)
VAR GroupedTable =
SUMMARIZE(
FilteredTable,
'Table'[Location],
"MedicalConcernsCount", COUNT('Table'[Incident Type])
)
VAR TopLocation =
TOPN(
1,
GroupedTable,
[MedicalConcernsCount],
DESC
)
RETURN
CONCATENATEX(
TopLocation,
'Table'[Location] & ", " & [MedicalConcernsCount],
", "
)
Proud to be a Super User! |
|
Hi @bhanu_gautam this is great thank you!
Sorry to be a pain but what would the measure look like if I didn't want the count number attached, Just the name of the top incident type, please?
Hi @RichOB ,
bhanu_gautam and Kedar have provided effective methods to obtain both the location and the top 1 count. You can make a slight adjustment to the measure below to include only the location:
Location with Top 1 Count =
VAR _tab =
SUMMARIZE (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Incident Type] = "Medical concern" ),
'Table'[Location],
"@Count", COUNT ( 'Table'[Incident Type] )
)
VAR _tab2 =
TOPN ( 1, _tab, [@Count], DESC )
RETURN
CONCATENATEX( _tab2, [Location],", " ,[Location],ASC)
Best Regards
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
115 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
164 | |
116 | |
63 | |
57 | |
50 |