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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
charlineklapu
Frequent Visitor

Measure filter min value per category

Hello all,

 

I want to have a measre which gives me the possibilty to filter for the min value (columns Days) within one case (column case). Data is used in direct query mode via analysis services. 

 

Data looks as followed:

CaseDateNameDays
1016.04.2022 00:00a2659,21
1016.04.2022 00:00b22,42
2016.04.2022 00:00c67,45
2016.04.2022 00:00a57,29
3014.04.2022 00:00a5572,92
3014.04.2022 00:00e239,08
4014.04.2022 00:00d36,81

 

The column days is also a measure (Calculate min with filter on a given status). Which will then let me filter on the lowest values and show all connected columns. Up top, you can see that one case number can show up twice, if the case had two groups, therefore the min value of each group (column Name) is shown. I want each case number only once.

 

What I want is the column flag:

 

CaseDateNameDaysFlag
1016.04.2022 00:00a2659,210
1016.04.2022 00:00b22,421
2016.04.2022 00:00c67,450
2016.04.2022 00:00a57,291
3014.04.2022 00:00a5572,920
3014.04.2022 00:00e239,081
4014.04.2022 00:00d36,811

 

and by filtering there will, one line per case:

 

CaseDateNameDaysFlag
1016.04.2022 00:00b22,421
2016.04.2022 00:00a57,291
3014.04.2022 00:00e239,081
4014.04.2022 00:00d36,811

 

 

Thank you!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @charlineklapu 
You may try

Flag =
VAR CurrentDate = 
    MAX ( Table[Date] )
VAR MinDaysValue =
    MINX (
        FILTER ( ALL( Table[Case] ), Table[Date] = CurrentDate ) ),
        [Days]
    )
RETURN
    [Days] = MinDaysValue 

Should return TRUE for min value

View solution in original post

12 REPLIES 12
v-yangliu-msft
Community Support
Community Support

Hi  @charlineklapu ,

Here are the steps you can follow:

1. Create measure.

Flag =
IF(
    [Days_Measure]=MINX(FILTER(ALL('Table'),'Table'[Case]=MAX('Table'[Case])),[Days_Measure]),1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1650609384557.png

3. Result:

vyangliumsft_1-1650609384559.png

 

Best Regards,

Liu Yang

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

Thank you. 

 

However this solution won't work for me as it just loads for a very long time and then returns the error message: "The reultset of a query to external data source has exceeded the maximum allowed size of 1.000.000 rows." 

 

Any other ideas? 

tamerj1
Super User
Super User

Hi @charlineklapu 
You may try

Flag =
VAR CurrentDate = 
    MAX ( Table[Date] )
VAR MinDaysValue =
    MINX (
        FILTER ( ALL( Table[Case] ), Table[Date] = CurrentDate ) ),
        [Days]
    )
RETURN
    [Days] = MinDaysValue 

Should return TRUE for min value

Thank you for your effort!

 

However this measure won't work as well ... 

Error message: OLE DB od ODBC erroro: You have reached the maximum allowable memory allocation for your tier. 

 

Any ideas on how to fix this? Or a different measure? 

 

Thank you!

Hi @charlineklapu 
Try 

Flag =
VAR CurrentDate = 
    MAX ( Table[Date] )
VAR MinDaysValue =
    MINX (
        FILTER ( ALLSELECTED( Table[Case] ), Table[Date] = CurrentDate ) ),
        [Days]
    )
RETURN
    [Days] = MinDaysValue 

Still not not working ... Same error message

@charlineklapu 

Try 

Flag =
VAR CurrentDate =
    MAX ( Table[Date] )
VAR MinDaysValue =
    MINX (
        CALCULATETABLE ( Table, ALLEXCEPT ( Table, Table[Case], Table[Date] ) ),
        Table[Days]
    )
RETURN
    MAX ( Table[Days] ) = MinDaysValue

First of all, thank you for your countinious help. 

 

But bad news, still not a solution for my problem. 

 

Now the error message: "The reultset of a query to external data source has exceeded the maximum allowed size of 1.000.000 rows." 

@charlineklapu 

Can you please place this measure in your table and screenshot the results?

measure1 =
    COUNTROWS (
        CALCULATETABLE ( Table, ALLEXCEPT ( Table, Table[Case], Table[Date] ) )
    )

Sorry, for the delay.

Find the measure attached.

charlineklapu_0-1651471328772.png

Am I doing something wrong?

@charlineklapu 

My friend. Please keep the four columns (case, date, name days) in the table

charlineklapu_1-1651481927033.png

 This works.

 

As soon as I also want to display "name", the error message appears.

 

Is it due to my model? I have a fact table and numerous dimension tabels. But I am missing one dimension, thats why I am connecting a table "GW Aktuell" where I am grouping users (found in dimension table) into groups. And I want to show only one duration per group (multiple users out of fact table into one group). 

charlineklapu_2-1651482065466.png

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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