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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
swaink
Regular Visitor

Count occurencies of one column if the week number in another column is the latest week no

Dear All

 

I am new to Powewr BI but I am truly enjoying what it is able to do fo rme

 

I have however hit a snag and am struggling with getting my head around a solution

 

In one column I have "Service Type" and in another column I have the week numbers

 

I am trying to create a measure that counts the number of occurencies of the "Service Type" if the Week number column is showing the latest week number (I.E the maximum week number in the column)  

 

Unfortunately I have hit a wall and can't see the solution would anyon ebe able to advise me please

 

Regards

 

Kevin

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Given this Enter Data query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk4tKstMTlUwVNJRMjZRitUhKGRohCJkhKkKLGSMImQMFYoFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Service = _t, WeekNum = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Service", type text}, {"WeekNum", Int64.Type}})
in
    #"Changed Type"

Create these measures:

 

MAXWeekNum = CALCULATE(MAX(Services[WeekNum]),ALL(Services))

CountWeekNum = COUNT(Services[WeekNum])

CountCurrentWeekNum = CALCULATE([CountWeekNum],FILTER(Services,Services[WeekNum] = [MAXWeekNum]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Given this Enter Data query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk4tKstMTlUwVNJRMjZRitUhKGRohCJkhKkKLGSMImQMFYoFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Service = _t, WeekNum = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Service", type text}, {"WeekNum", Int64.Type}})
in
    #"Changed Type"

Create these measures:

 

MAXWeekNum = CALCULATE(MAX(Services[WeekNum]),ALL(Services))

CountWeekNum = COUNT(Services[WeekNum])

CountCurrentWeekNum = CALCULATE([CountWeekNum],FILTER(Services,Services[WeekNum] = [MAXWeekNum]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi smoupre

 

Thank you for the swift reply it is appreciated

 

I have applied the measures as you suggested and that has indeed solved my problem thank you

 

Kevin

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.