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

Be 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

Reply
Lukas90
New Member

DAX

Hi,

 

I need to write a measure that will be calculated on the chart only for the smaller of the selected years. That is, if I select 2023 and 2024 on the slicer, I only want to see the value for 2023 (i.e. one bar) on the chart. On the X axis there will still be 2023 and 2024 because they are needed for other measures. That is, I need remove one right, blue bar (gray is another measure that counts well).

 

Thanks!

 

Lukas90_0-1726228351130.png

 

1 ACCEPTED SOLUTION

yes you are right. The issue was due to an oversight on my part. you should write it as follows...

 

var min_year = calculate( min ('date' [year]) , allselected ('date' [year]))

View solution in original post

9 REPLIES 9
dk_dk
Super User
Super User

Hi @Lukas90 

I have a half solution that works, but will keep all the years on the x axis visible at all times:

 

SelectiveVis table has a Year column and two measures (Correct and Wrong, correct is the one you want to show on all years, wrong is the one you want to show only on the min year) based on 2 columns

I create a separate table (yrhlp) that only has one year column.

Then a third measure:

HiddenMeasure =

VAR minYear = MIN(yrhlp[yr])

VAR val = CALCULATE([Wrong Measure],SelectiveVis[Year]=minYear)

RETURN
IF(MAX(SelectiveVis[Year])=minYear,val,"")



Then configure relationship as follows:

 

dk_dk_0-1726231534637.png

 

In your visual, use the year from SelectiveVis as the axis, but in your slicer use the year from yrhlp.


Here is how it looks:

dk_dk_1-1726231628462.png

 

 

dk_dk_2-1726231648801.png

 

 

Couldnt find a way to get rid of the blank 2022 column unfortunately. But in terms of showing the measure only on the min year, it does what you were after.

 

Hope it helps a little!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Lukas90
New Member

@Selva-Salimi

 

I have dim date. 

 

If I choose two years I still see two blue bars unfortunately:(

@Lukas90 

 

so you should write it as follows:

var min_year = calculate( min ('date' [year]) , allselected ('date' , 'date' [year]))

 

If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

Still doesn't work:(

@Lukas90 

 

I test this measure and it works!. what is the table of X axis (years)?

I removed table reference and now it works! Many Thanks!

Yes, for this second option I got "Multiple arguments are not allowed in the ALLSELECTED function when the first argument is a table reference."

yes you are right. The issue was due to an oversight on my part. you should write it as follows...

 

var min_year = calculate( min ('date' [year]) , allselected ('date' [year]))

Selva-Salimi
Solution Specialist
Solution Specialist

Hi @Lukas90 

 

you can update your measure as follows:

measure _min :=

var min_year = min ('date' [year]) (if you dont have dim date you should use all or allselected)

return

if (selectedvalue(year) = min_year , blue_measure , 0 )

 

If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.