cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Murali777
Helper III
Helper III

Find Min value and overlap value using DAX table

Hello,

 

I have already creatd the summarize table with below columns (step1), And my
step 2 is to find the min value from the different strategy and same name.
Step 3 : Final out put is, Total Number of strategy from my first step and overlap count from the second step.

Murali777_1-1651516509552.png

 

Step 3 is my expected output in the calculated table.

1 ACCEPTED SOLUTION

Hi,

Thank you for your message.

It is for creating a new table, and not for a measure.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

7 REPLIES 7
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if my DAX formula meets your need, but I created the below picture and the attached pbix file based on the sample.

It is for creating a new table.

 

Slide1.jpg

 

New Table = 
VAR _newtable =
    FILTER (
        Data,
        COUNTROWS ( FILTER ( Data, Data[Name] = EARLIER ( Data[Name] ) ) ) = 2
    )
VAR _minvaluetable =
    CALCULATETABLE (
        Data,
        TREATAS (
            GROUPBY (
                _newtable,
                Data[Date],
                Data[Name],
                "@MinValue", MINX ( CURRENTGROUP (), Data[SumofValues] )
            ),
            Data[Date],
            Data[Name],
            Data[SumofValues]
        )
    )
RETURN
    ROW (
        "AppleTotal", COUNTROWS ( FILTER ( Data, Data[Strategy] = "Apple" ) ),
        "MangoTotal", COUNTROWS ( FILTER ( Data, Data[Strategy] = "Mango" ) ),
        "Overlap", COUNTROWS ( _minvaluetable )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi Jihwan,

 

Thank you for your coding. It almost working, i'm at the final stage. In step 3 i need to add the total row. Kindly help me on this final step.

 

Murali777_1-1651572285332.png

 

Hi,

Please check the attached file and the below DAX formula to create a new table.

 

New Table =
VAR _newtable =
    FILTER (
        Data,
        COUNTROWS ( FILTER ( Data, Data[Name] = EARLIER ( Data[Name] ) ) ) = 2
    )
VAR _minvaluetable =
    CALCULATETABLE (
        Data,
        TREATAS (
            GROUPBY (
                _newtable,
                Data[Date],
                Data[Name],
                "@MinValue", MINX ( CURRENTGROUP (), Data[SumofValues] )
            ),
            Data[Date],
            Data[Name],
            Data[SumofValues]
        )
    )
VAR _appletotal =
    { COUNTROWS ( FILTER ( Data, Data[Strategy] = "Apple" ) ) }
VAR _mangototal =
    { COUNTROWS ( FILTER ( Data, Data[Strategy] = "Mango" ) ) }
VAR _overlap =
    { COUNTROWS ( _minvaluetable ) }
VAR _minvalueappletotal =
    {
        SUMX ( FILTER ( _minvaluetable, Data[Strategy] = "Apple" ), Data[SumofValues] )
    }
VAR _minvaluemangototal =
    {
        SUMX ( FILTER ( _minvaluetable, Data[Strategy] = "Mango" ), Data[SumofValues] )
    }
VAR _totaloverlap =
    { SUMX ( _minvaluetable, Data[SumofValues] ) }
RETURN
    UNION (
        ROW (
            "AppleTotal", _appletotal,
            "MangoTotal", _mangototal,
            "Overlap", _overlap
        ),
        ROW (
            "AppleTotal", _minvalueappletotal,
            "MangoTotal", _minvaluemangototal,
            "Overlap", _totaloverlap
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi Jihwan Sir,

 

It is not showing the second row. 

Murali777_0-1651585846384.png

 

Hi,

Thank you for your message.

It is for creating a new table, and not for a measure.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thank you Jihwan 🙂

Murali777
Helper III
Helper III

@Jihwan_Kim Hello sir, pls help me on this.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors