Forum Discussion

Laufer_Israel's avatar
6 years ago

Returns only first row with lookupvalue

Hi all,

I have a table as can be seen below and I would like to see only the first row for "Total sales 2018" column.

It is important to note that "Total sales 2018" is a data which has been taken from another table with LOOKUPVALUE DAX.

Does it is possible to see only the first row for each customer?? (in order to avoid duplication)

Many thanks in advance.

CodeNameProductQuantityTotal sales 2018
1OnePP2220
1OneSS3220
1OneYY4220
1OneMM9220
2TwoPP1167
2TwoSS4167
2TwoYY7167
2TwoMM2167
3ThreePP3701
3ThreeSS1701
3ThreeYY3701
3ThreeMM8701

14 Replies

  • Jimmy801's avatar
    Jimmy801
    Icon for Community Champion rankCommunity Champion

    Hello Laufer_Israel ,

     

    Apply a grouping with the columns that have distinct values. (Code, Name, Total sales). Here an example

    let
    	Source = #table
    	(
    		{"Code","Name","Product","Quantity","Total sales 2018"},
    		{
    			{"1","One","PP","2","220"},	{"1","One","SS","3","220"},	{"1","One","YY","4","220"},	{"1","One","MM","9","220"},	{"2","Two","PP","1","167"},	{"2","Two","SS","4","167"},	
    			{"2","Two","YY","7","167"},	{"2","Two","MM","2","167"},	{"3","Three","PP","3","701"},	{"3","Three","SS","1","701"},	{"3","Three","YY","3","701"},	{"3","Three","MM","8","701"}
    
    					}
    	),
        ChangeType = Table.TransformColumnTypes(Source,{{"Code", Int64.Type}, {"Name", type text}, {"Product", type text}, {"Quantity", Int64.Type}, {"Total sales 2018", Int64.Type}}),
        Group = Table.Group(ChangeType, {"Code", "Name", "Total sales 2018"}, {{"AllRows", each _, type table [Code=number, Name=text, Product=text, Quantity=number, Total sales 2018=number]}})
    in
    	Group

     

    Copy paste this code to the advanced editor to see how the solution works. You can apply it by copying a part of my code to your query, or I can help you to apply a custom function

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy

    • Laufer_Israel's avatar
      Laufer_Israel
      Icon for Helper I rankHelper I

      Thank you Jimmy for your prompt comment.

      Since the data in my question is only an example of my issue, your recomendation is'nt valid on this case.

      Actually what I would like to do, is to add another column that will show only the first row from "Total sales 2018" for each customer and will leave the rest of the rows for each customer blank.\

      Does it possible??

      • Laufer_Israel's avatar
        Laufer_Israel
        Icon for Helper I rankHelper I

        The right column it is what I am looking for.

        CodeNameProductQuantityTotal sales 2018Total sales 2018
        1OnePP2220220
        1OneSS3220 
        1OneYY4220 
        1OneMM9220 
        2TwoPP1167167
        2TwoSS4167 
        2TwoYY7167 
        2TwoMM2167 
        3ThreePP3701701
        3ThreeSS1701 
        3ThreeYY3701 
        3ThreeMM8701