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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to calculate MIN/MAX week of Value and Value of MIN Week as per MIN year

Hi Team,

I have 4 columns in my table.I need to calculate MIN/MAX Week of as per MIN/MAX value in particulator Dept . I need to calculate value of MIN week in particualr dept. I have to calculate four measure.

Measure1= MIN Week of Value (format:- Year-Week)

Measure2= MAX Week of Value (format:- Year-Week)

Measure3= MIN Week of min year(format:- Year-Week)

Measure4= Value of Measure3

 

For Example of Dept1 in table :-Min value is 43685 , I need to calculate  week of this value is 10 (2022-2).Max value is 85601 , I need to calculate  week of this value is 9 (2020-9). I need to calculate MIN Week is 4 as per year Min 2020 then i need to calculate value of this week is 69826.

Sample Data:-

Capture.PNG

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

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may create measures as below.

MaxValue = 
CALCULATE(
    MAX('Table'[Value]),
    ALLEXCEPT('Table','Table'[Dept])
) 
MaxValue Weeks = 
CONCATENATEX(
    FILTER(
        'Table',
        'Table'[Value]=[MaxValue]
    ),
    [YearWeek],
    ","
)
MinValue = 
CALCULATE(
    MIN('Table'[Value]),
    ALLEXCEPT('Table','Table'[Dept])
)
MinValue Weeks = 
CONCATENATEX(
    FILTER(
        'Table',
        'Table'[Value]=[MinValue]
    ),
    [YearWeek],
    ","
)
MinWeek Value = 
var minweek = 
CALCULATE(
    MIN('Table'[YearWeek]),
    ALLEXCEPT('Table','Table'[Dept])
)
return
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        ALLEXCEPT('Table','Table'[Dept]),
        [YearWeek]=minweek
    )
)

 

Result:

a2.png

 

 

Best Regards

Allan

 

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-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may create measures as below.

MaxValue = 
CALCULATE(
    MAX('Table'[Value]),
    ALLEXCEPT('Table','Table'[Dept])
) 
MaxValue Weeks = 
CONCATENATEX(
    FILTER(
        'Table',
        'Table'[Value]=[MaxValue]
    ),
    [YearWeek],
    ","
)
MinValue = 
CALCULATE(
    MIN('Table'[Value]),
    ALLEXCEPT('Table','Table'[Dept])
)
MinValue Weeks = 
CONCATENATEX(
    FILTER(
        'Table',
        'Table'[Value]=[MinValue]
    ),
    [YearWeek],
    ","
)
MinWeek Value = 
var minweek = 
CALCULATE(
    MIN('Table'[YearWeek]),
    ALLEXCEPT('Table','Table'[Dept])
)
return
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        ALLEXCEPT('Table','Table'[Dept]),
        [YearWeek]=minweek
    )
)

 

Result:

a2.png

 

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

lbendlin
Super User
Super User

Please provide sample data in usable format and specify if you need this in Power Query or in DAX

 

Anonymous
Not applicable

Thanks for you reply. I need this in DAX. please have a look below sample table.

 

 

sample 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors