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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Pawel_C
Frequent Visitor

Why my measure won't recalculate with slicers?

Hi Guys!
I have tried to find help with a good old friend Copilot, but he's not clever enough to point me out my mistakes or propose good direction.

Here's the issue. I use the date table in a format as follows for my dashboard:

 

dateDescriptionAttributeContractDateValue
29.08.2024Space InvadersGame A 111
29.08.2024ArcanoidGame B 112
30.08.2024Space InvadersGame A 113
30.08.2024ArcanoidGame B 114
29.08.2024Teddy BearToy ANov24/Jan2556
30.08.2024Teddy BearToy ANov24/Jan2560
29.08.2024DollToy BOct2465
30.08.2024DollToy BOct2464
29.08.2024RC CarToy CSep2458
30.08.2024RC CarToy CSep2459

 

In my visualisation I have slicers to switch between Attributes within the group of products (like switch between Game A and Game B) etc. I need to calculate a spread value between any 'Game' and any 'Toy' and want a measure to give me a proper spread based on which 'Game' or 'Toy' I select in a slicer.
The measure I came up with (and don't work as intended) looks like this:

SpreadLatestQuote = 
VAR LatestGAMEDate =
    CALCULATE(
        MAX('THIS YEAR'[date]),
        'THIS YEAR'[Attribute] IN {"Game A", "Game B"}
    )
VAR LatestTOYDate =
    CALCULATE(
        MAX('THIS YEAR'[date]),
        'THIS YEAR'[Attribute] IN {"Toy A", "Toy B", "Toy C"}
    )
VAR GAMEValue =
    CALCULATE(
        AVERAGE('THIS YEAR'[Value]),
        'THIS YEAR'[Attribute] IN {"Game A", "Game B"},
        'THIS YEAR'[date] = LatestGAMEDate
    )
VAR TOYValue =
    CALCULATE(
        AVERAGE('THIS YEAR'[Value]),
        'THIS YEAR'[Description] IN {"Toy A", "Toy B", "Toy C"},
        'THIS YEAR'[date] = LatestToyDate
    )
RETURN
    GAMEValue - TOYValue

Caveat is, that not all toys or games are quoted daily, hence comparison between latest date for both.

What's wrong with my measure? Thanks in advance for your feedback


1 ACCEPTED SOLUTION
Pawel_C
Frequent Visitor

Thank you for the answer, however I just misspelled "TOY" while I have been anonymizing my code for pasting here. In the real one I don't have VAR name issues. The code itself does not react to the slicer selections.

View solution in original post

2 REPLIES 2
Pawel_C
Frequent Visitor

Thank you for the answer, however I just misspelled "TOY" while I have been anonymizing my code for pasting here. In the real one I don't have VAR name issues. The code itself does not react to the slicer selections.

bhanu_gautam
Super User
Super User

@Pawel_C , Try updated measure

 

SpreadLatestQuote =
VAR LatestGAMEDate =
CALCULATE(
MAX('THIS YEAR'[date]),
'THIS YEAR'[Attribute] IN {"Game A", "Game B"}
)
VAR LatestTOYDate =
CALCULATE(
MAX('THIS YEAR'[date]),
'THIS YEAR'[Attribute] IN {"Toy A", "Toy B", "Toy C"}
)
VAR GAMEValue =
CALCULATE(
AVERAGE('THIS YEAR'[Value]),
'THIS YEAR'[Attribute] IN {"Game A", "Game B"},
'THIS YEAR'[date] = LatestGAMEDate
)
VAR TOYValue =
CALCULATE(
AVERAGE('THIS YEAR'[Value]),
'THIS YEAR'[Attribute] IN {"Toy A", "Toy B", "Toy C"},
'THIS YEAR'[date] = LatestTOYDate
)
RETURN
GAMEValue - TOYValue




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors