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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
harshagraj
Post Partisan
Post Partisan

Filtering max week by max non blank amount and max year

Hi all,

Please refer to the below data. I need a help to Prepare a KPI chart where i have to display Current week and previous weeks amount.

For current year i am using this 

curentyear = IF(ISBLANK(SUM('Table'[Amount])),"",MAX('Table'[Year Id])).
I need to get current week in current year and it should exclude blank in amount column. Presently it has 1-52 weeks in week column.
Also i have to display previous 6 weeks trend.
WeekAmount Year Id
129292018
146902019
118482020
226142018
225402019
210352020
342482018
332352019
339412020
436072018
445872019
419442020
544392018
512112019
532042020
617822018
632992019
617972020
728052018
731732019
727822020
821382018
815442019
839262020
923852018
931852019
940192020
1035742018
1020532019
1044342020
1141602018
1132822019
1136742020
1225142018
1238282019
1218542020
1345072018
1347342019
1348782020
1449782018
1442832019
1412982020
1546712018
1542352019
1533102020
1637532018
1613512019
1648512020
1725932018
1743122019
1730822020
1841842018
1841442019
1830232020
1925942018
1930502019
1910992020
2018262018
2016752019
2018242020
2140562018
2146702019
2141982020
2220252018
2229792019
2211062020
2330232018
2327722019
2340482020
2419672018
2447372019
2410682020
2547972018
2510022019
2515162020
2633402018
2635902019
2630982020
2718882018
2744172019
2735302020
2818532018
2848662019
2910522018
2914682019
3018542018
3035262019
3129272018
3133462019
3211582018
3228422019
3349112018
3323702019
3415022018
3423752019
3545082018
3516832019
3632612018
3618752019
3724652018
3735252019
3831422018
3843452019
3936822018
3918542019
4032722018
4033112019
4124192018
4140502019
4228002018
4210392019
4334122018
4321002019
4434852018
4424172019
4547402018
4518202019
4616302018
4625882019
4725782018
4714002019
4841952018
4828722019
4914332018
4948502019
5045072018
5020512019
5147152018
5115182019
5219102018
5227102019

 

6 REPLIES 6
Greg_Deckler
Super User
Super User

So perhaps:

 

Current Week in Current Year Measure:
  VAR __CurrentYear = MAX('Table'[Year Id])
  VAR __CurrentWeek = MAXX(FILTER('Table',[Year Id]=__CurrentYear),[Week])
RETURN
  __CurrentWeek


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 @Greg_Deckler  thanks a lot for the reply. Its actually displaying 52 for 2020. Actually it should display 27. In 2020 there is no amount after 27.

Current Week in Current Year Measure:
  VAR __CurrentYear = MAX('Table'[Year Id])
  VAR __CurrentWeek = MAXX(FILTER('Table',[Year Id]=__CurrentYear) && NOT(ISBLANK([Amount])),[Week])
RETURN
  __CurrentWeek


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 thanks for the reply do you mean NOT(ISBLANK(SUM(Amount))). If i use SUM then i am getting The expressions refers to multiple columns and cannot be converted to a scalar value.

@harshagraj 
That dax is used to create a calculate column, for a measure:

 

Measure = CALCULATE(MAX('Table'[Week]),FILTER(ALL('Table'),MAXX(FILTER('Table',EARLIER('Table'[ Year Id])='Table'[ Year Id]),1)),'Table'[Amount]<>BLANK())

 

 

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

Hi @V-pazhen-msft  thanks for the reply. It is still showing 52 instead of 29(Max Week).

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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