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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AndreaPRJ
Helper I
Helper I

Show in a Table totals for max and min Year Selected in Filter..

..regardless of the year added in the tablecolumn.

Hi to all!

In my report I have a total of 6.594 calls divided as follows per year:

2019: 1138 

2020: 1535

2021: 2376

2022: 1545

I have a slicer with which the user can choose two years to compare and one simple table with these measures:

TotalCalls:= COUNT(CALLS[NUMEROSTEP])

MaxYear:=CALCULATE(TotalCalls;

    FILTER (ALLSELECTED(CALLS[DATE]);
    year(CALLS[DATE]) = [Max Year Selected]))

MinYear:=CALCULATE([TotalCalls];

    FILTER (ALLSELECTED(CALLS[DATE]);
    year(CALLS[DATE]) = [Min Year Selected]))
Max Year Selected = Max(CALLS[DATE].[Year])
Min Year Selected = Min(CALLS[DATE].[Year])
 
with NO filter selected:

Immagine 2022-05-03 155341.jpg

If I choose two years from the slicer, all ok! and I see 2.376 under Max Year and 1.535 under Min Year 

 

 

Immagine 2022-05-03 155502.jpg

 However, if I add the year ("Anno column in italian..)  in front of the existing fields in my table, the data begins to not come out as I would like, because I imagine the filter context of the year is added

 

 

Immagine 2022-05-03 155825.jpg

 

In the firt raw (YEAR 2020), I would like to see 2.376 under Max Year and 1.535 under Min Year

In the second raw (YEAR 2021), I would like to see the same

 

I tried with REMOVEFILTERS ,ISINSCOPE and others but i did not solve 😞

I'm just starting out with dax

 

The final objective will then be to show the data in a matrix with the Year \ Month structure on the left and as values ​​the two measures with the calls of the year max and year min

 

PS: how could I limit the choice in the year filter to ONLY two years and no more than two?

THANK YOU VERY MUCH in advance

 

 

1 ACCEPTED SOLUTION

Hi @AndreaPRJ 

You can try this, create the measures below,

Max Year Selected = MAXX(ALLSELECTED('Table'),'Table'[Year])
Min Year Selected = MINX(ALLSELECTED('Table'),'Table'[Year])
MaxYear = CALCULATE(MAX('Table'[Qty]),FILTER(ALL('Table'),'Table'[Year]=[Max Year Selected]))
MinYear = CALCULATE(MAX('Table'[Qty]),FILTER(ALL('Table'),'Table'[Year]=[Min Year Selected]))

result

vxiaotang_0-1652853572757.png

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

4 REPLIES 4
AndreaPRJ
Helper I
Helper I

hi amitchandak, first of all thank you.

Unfortunately with your two measures I would get this .. with "holes".

Immagine 2022-05-04 091128.jpg

 

I would ALWAYS want both columns full, where the first shows me the number of calls for the maximum year among those selected and the second for the minimum year.

PS: the second option of your measurements would remove a couple of other active filters at the report level and therefore I do not take it into consideration

Bye

Hi @AndreaPRJ 

You can try this, create the measures below,

Max Year Selected = MAXX(ALLSELECTED('Table'),'Table'[Year])
Min Year Selected = MINX(ALLSELECTED('Table'),'Table'[Year])
MaxYear = CALCULATE(MAX('Table'[Qty]),FILTER(ALL('Table'),'Table'[Year]=[Max Year Selected]))
MinYear = CALCULATE(MAX('Table'[Qty]),FILTER(ALL('Table'),'Table'[Year]=[Min Year Selected]))

result

vxiaotang_0-1652853572757.png

 

Best Regards,

Community Support Team _Tang

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

Thank you very much and very sorry for the delay!

amitchandak
Super User
Super User

@AndreaPRJ , try like

 

MaxYear:=
Var _max = maxx(allselected('CALLS') , 'CALLS'[Year])
return
CALCULATE(TotalCalls;
FILTER (CALLS; year(CALLS[DATE]) = _max))

MinYear:=
Var _max = minx(allselected('CALLS') , 'CALLS'[Year])
return
CALCULATE(TotalCalls;
FILTER (CALLS; year(CALLS[DATE]) = _max))

 

 

or

 

MaxYear:=
Var _max = maxx(allselected('CALLS') , 'CALLS'[Year])
return
CALCULATE(TotalCalls;
FILTER (all(CALLS); year(CALLS[DATE]) = _max))

MinYear:=
Var _max = minx(allselected('CALLS') , 'CALLS'[Year])
return
CALCULATE(TotalCalls;
FILTER (all(CALLS); year(CALLS[DATE]) = _max))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors