Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
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!!
Solved! Go to Solution.
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]))
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.
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]))
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 - 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
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 67 | |
| 62 |