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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Measure to show Min and Max week Number from what is shown on Visual

Hi,

Need help with Dax, I have a 3 dimension DimStore, DimComp , DimDate with one fact table FactSales. I want to Measure which returns the min week and max week number by each store and compstatusdescription.MinMaxDax.png

Based on the screeshot I attached for storeNumber 600 and compStatusDesctiption Comp Min week should be 5 and Max week is 14 . For Non comp the Min week should return 1 and Max week as 4.

 

Any help is appreciated, Thanks!!

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a column in fact table

related_weeknum = RELATED('date'[weeknum])

Then create measures

Max = CALCULATE(MAX('fact'[related_weeknum]),ALLEXCEPT('fact','fact'[comp],'fact'[store]))

Min = CALCULATE(Min('fact'[related_weeknum]),ALLEXCEPT('fact','fact'[comp],'fact'[store]))

7.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then 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-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a column in fact table

related_weeknum = RELATED('date'[weeknum])

Then create measures

Max = CALCULATE(MAX('fact'[related_weeknum]),ALLEXCEPT('fact','fact'[comp],'fact'[store]))

Min = CALCULATE(Min('fact'[related_weeknum]),ALLEXCEPT('fact','fact'[comp],'fact'[store]))

7.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@Anonymous  - You need to start with the data model - Presumably your dimension tables don't filter each other. One possibility (not recommended) is to set up bi-directional filtering between the fact and date dimension. Another possibility is to add a Calculated Column to the fact table, like this:

weekNumber = RELATED(DimDate[weekNumber])

And then create Measures like this:

Max Week = MAX(FactSales[weekNumber])
Min Week = MIN(FactSales[weekNumber])

Hope this helps,

Nathan

Cmcmahan
Resident Rockstar
Resident Rockstar

Sure, this is easy enough. You'll need 4 measures, one for CompMinWeek, CompMaxWeek, NoncompMinWeek, & NoncompMaxWeek.  Change the values as necessary for each one:

CompMinWeek = CALCULATE( MIN(DimDate[weekNumber]), FactSales[CompStatusDescription] = "Comp")

Depending on how your tables are related to each other, you may need to edit this a little more heavily.  If you have further questions about any errors you get, please include a screenshot or the full text of the error and your table relationships.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (7,435)