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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

DAX measure how to add ALL, ALLEXCEPT... logic

Hi, I need some DAX help.

I created a table -> Parameter = GENERATESERIES(0, 50, 10) -> and use this in the slicer 'Control Reports'.

I create a measure to calculate the number of document per store and included the parameter value as a filter. 

 

Measure = 
VAR CountDocId = DISTINCTCOUNT('TEST DATA'[DOC ID])
VAR ParameterFilter = CountDocId >= Parameter[Parameter Value]
VAR Display = IF(ParameterFilter, CountDocId, BLANK())
RETURN
Display​


But is does not exactely what I want. 

 

If the number of documents in all the selected week columns is lower than the slicer Control Reports then don't show the store in the table (this works with my measure). 
If the number of documents in one of the selected week columns is equal or higher than the slicer Control Reports then show all the values for that store in the table (this does not work with my measure).

I suppose I need to add ALL or ALLEXCEPT or something like that. But I can't figure it out... 


Here example:

JulieB__0-1638466795336.png

Store Ostende has more than 20 documents in several weeks. The store must be included in the table and also weeks with less than 20 docs must be displayed. That how I would like it.

JulieB__1-1638466801705.png

Some sample data: 

DOC IDDATEAMOUNTSTORE IDSTORE NAME
325199452/01/2021€ 21410014082Brussel
325220882/01/2021€ 39010014082Brussel
325221362/01/2021€ 19210014082Brussel
325223312/01/2021€ 1510042955Charleroi
325246262/01/2021€ 13010046642Lommel
325246442/01/2021€ 11710046642Lommel
325247232/01/2021€ 2.39910014082Brussel
325283193/01/2021€ 10510046642Lommel
325318744/01/2021€ 11510014076Lille
325363224/01/2021€ 17510042955Charleroi
325368434/01/2021€ 13310046642Lommel
325369004/01/2021€ 6310046642Lommel
325410405/01/2021€ 12310014076Lille
325412655/01/2021€ 8010046642Lommel
325417385/01/2021€ 4410014076Lille
325441725/01/2021€ 7410042955Charleroi
325450895/01/2021€ 27910014082Brussel

Can anyone help out?


Kind regards,
Julie 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Try this,

create the measures,

selectedValue = SELECTEDVALUE('Control reports'[Parameter])
total_Pername_PerWeek = CALCULATE(SUM('TEST DATA'[AMOUNT]),FILTER(ALLSELECTED('TEST DATA'),'TEST DATA'[STORE NAME]=MIN('TEST DATA'[STORE NAME]) && WEEKNUM('TEST DATA'[DATE])=WEEKNUM( MIN('TEST DATA'[DATE]))))
Test = 
var _maxForEachName=MAXX(FILTER(ALLSELECTED('TEST DATA'),'TEST DATA'[STORE NAME]=MIN('TEST DATA'[STORE NAME])),[total_Pername_PerWeek])
return IF(_maxForEachName>[selectedValue],SUM('TEST DATA'[AMOUNT]))

result

vxiaotang_2-1638944728998.pngvxiaotang_3-1638944745504.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

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Try this,

create the measures,

selectedValue = SELECTEDVALUE('Control reports'[Parameter])
total_Pername_PerWeek = CALCULATE(SUM('TEST DATA'[AMOUNT]),FILTER(ALLSELECTED('TEST DATA'),'TEST DATA'[STORE NAME]=MIN('TEST DATA'[STORE NAME]) && WEEKNUM('TEST DATA'[DATE])=WEEKNUM( MIN('TEST DATA'[DATE]))))
Test = 
var _maxForEachName=MAXX(FILTER(ALLSELECTED('TEST DATA'),'TEST DATA'[STORE NAME]=MIN('TEST DATA'[STORE NAME])),[total_Pername_PerWeek])
return IF(_maxForEachName>[selectedValue],SUM('TEST DATA'[AMOUNT]))

result

vxiaotang_2-1638944728998.pngvxiaotang_3-1638944745504.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.

ahmedoye
Responsive Resident
Responsive Resident

Try using this pattern below:

 

Counts =
VAR CountDocs =
    CALCULATE (
        DISTINCTCOUNT ( 'DataTable'[DOC ID] ),
        ALLEXCEPT ( 'DataTable', 'DataTable'[STORE NAME] )
    )
VAR CheckLimit =
    SELECTEDVALUE ( Parameter[Parameter] )
VAR SelectedStore =
    SELECTEDVALUE ( 'DataTable'[STORE NAME] )
VAR TableVisible =
    FILTER (
        ALL ( 'DataTable'[STORE NAME] ),
        'DataTable'[STORE NAME] = SelectedStore
            && CALCULATE ( CountDocs ) >= CheckLimit
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'DataTable'[DOC ID] ),
        'DataTable'[STORE NAME] IN TableVisible
    )

 

aaa.PNG

 

If this solution works for you, kindly mark as solution to allow others who may have similar challenge find it easily.

Anonymous
Not applicable

Thank you for helping out  @ahmedoye !
The measure is almost ok. The measure should filter the table based on the documents per week (not total documents on the selected period). If the number of control reports for one week is equal or above the number of control reports selected on the slicer then show the store and number of document for all the selected weeks. 


In the screenshot below is the result of your measure. 
Charleroi, Lommel and Paris should not show in the table because none of the weeks is above 18 control reports. 
Brussel and Ostende should be displayed because some weeks are above the 18 control reports. 

2021-12-06_11h55_23.png

I tried to correct the measure but am not sure how to. 
The part in red wrongly filters the table but I don't know how to change it correctly...

2021-12-06_11h57_38.png

Thanks for helping out!  

Greetings, Julie

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.