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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Measure with filter in DAX

Dear ,

 

Could you please advise for the formula of DAX in measure below?

 

Context: I want that when I filter the value of week in a slicer, the matrix with column is the week and value (is result from a measure % Accuracy) should be displayed only the selected weeks.

 

Issue: The current measure returns value is 100% for weeks not selected.

 

If I select a week in slicer is week 30.2021 => It should disappear value of week 20.2021->28.2021. But in this matrix, the value still exists with 100% (The correct value is not 100%).

 

Nguyen_1-1628435006256.png

 

 

Formual for measure:

% Accuracy = if(
and(sum('RMP Manual SharePoint'[Demand-BW (Qty)])=0, sum('RMP Manual SharePoint'[Total requirement (W. - W.)])=0),
1,
divide(sum('RMP Manual SharePoint'[Demand-BW (Qty)]),sum('RMP Manual SharePoint'[Total requirement (W. - W.)])))
 
Appreciate your support!
 
 

 

 

 

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@Anonymous Perhaps:

% Accuracy = 
    VAR __SelectedWeek = MAX(SlicerTable[Week])
    VAR __CurrentWeek = MAX(Table[Week])
RETURN
    if(__SelectedWeek = __CurrentWeek,
      if(
        and(sum('RMP Manual SharePoint'[Demand-BW (Qty)])=0, sum('RMP Manual SharePoint'[Total requirement (W. - W.)])=0),
        1,
        divide(sum('RMP Manual SharePoint'[Demand-BW (Qty)]),sum('RMP Manual SharePoint'[Total requirement (W. - W.)]))
      ),
      BLANK()
  )

Seems like you ought to also be able to solve this by using the same column for your slicer as you do for your columns in your matrix? The current measure is returning 100% because you return a 1 in your TRUE case. You could also adjust that test condition to account for figuring out if the week is the chosen week. I did this in a nested if statement. Probably might want to consider switching to SWITCH(TRUE()...)



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors