Forum Discussion

Zaibsrule88's avatar
Zaibsrule88
Frequent Visitor
4 years ago
Solved

what if date is same

I'm new on PBI, working on a report where Ive to show QTY for a user for specific day - Problem is if user go out twice or more Ive to show only assign QTY.

 

DateNameAssigned QTY 
8/27/2022JOHN35
8/27/2022JOLYY35
8/27/2022JOHN35
  105

 

This is what I need

DateNameAssigned QTY 
8/27/2022JOHN35
8/27/2022JOLYY35
8/27/2022JOHN 
  70

 

  • Jeanxyz's avatar
    Jeanxyz
    4 years ago

    littlemojopuppy , have you created a messure called AssignedQTY and remove duplicates in that measure? If you simply sum up AssignedQTY, that won't remove the duplicates. To remove the duplicate, you need to

     

    1. in the fact table, create a new column to calculate the number of times a name appearing on a specific day. If a name appear twice on the same day, column duplicate count will generate 2.

    2. create a measure to make sure if a name appear more than once on the same day, the total QTY should be divided by duplicate count. Below is the table showing the correct QTY.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Zaibsrule88 

     

    Please new a measure.

     

    Total =
    VAR _table =
        SUMMARIZE ( 'Table', 'Table'[Code], 'Table'[Date], 'Table'[AvailableCap] )
    VAR _total =
        SUMX ( _table, 'Table'[AvailableCap] )
    RETURN
        _total

     

    The PBIX file is attached for reference.

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

10 Replies

  • littlemojopuppy's avatar
    littlemojopuppy
    Community Champion

    Hi Zaibsrule88.  Define a measure for Total QTY = SUM(AssignedQTY).  On a matrix visual, drop date and name in rows and the measure Total QTY for values.

     

    There's no need to alter the underlying table for this.  Hope this helps!

    • Zaibsrule88's avatar
      Zaibsrule88
      Frequent Visitor

      First of all Thank you for your response and really appriciate it,

      I will try to explain the issue in more detail/

      I have to assign a fixed target to each member " lets say forty"

      sometimes name appears twice in a date and the problem is I dont have to remove it , I want build a way that if name appears twice in a day I assign a fixed value to that particular name only once,

       

      lets say 

       

      abc 40

      xyz  40 

      abc "Repeated" "Should be 0 " because its repeated twice in same day

       

       

      • littlemojopuppy's avatar
        littlemojopuppy
        Community Champion

        Zaibsrule88 I don't believe you should have to alter data to achieve this.  It sounds like the kind of thing that could be handled in a visual or in how a measure is defined.  Can you provide some sample data to play with?

    • Jeanxyz's avatar
      Jeanxyz
      Power Participant

      littlemojopuppy , have you created a messure called AssignedQTY and remove duplicates in that measure? If you simply sum up AssignedQTY, that won't remove the duplicates. To remove the duplicate, you need to

       

      1. in the fact table, create a new column to calculate the number of times a name appearing on a specific day. If a name appear twice on the same day, column duplicate count will generate 2.

      2. create a measure to make sure if a name appear more than once on the same day, the total QTY should be divided by duplicate count. Below is the table showing the correct QTY.

  • Jeanxyz's avatar
    Jeanxyz
    Power Participant

    Zaibsrule88 

    Correct me if I get you wrong. In your original table (e.g., fact_QTY ) duplicate recored are created because a new record is generated each time a user goes out or moves. To remove duplicate records, you can create a summary table as below. 

    fact_QTY_summarize=summarize(fact_QTY,  fact_QTY[Date], fact_QTY[NameAssigned QTY])

     

    • littlemojopuppy's avatar
      littlemojopuppy
      Community Champion

      Jeanxyz it's not a good idea to start creating tables to support individuial visualizations.  Create a nice, clean star/snowflake design and write measures appropriately.

       

      I'm also thinking there needs to be some thought about repeating ABC twice in the same day in a visualization.

    • Zaibsrule88's avatar
      Zaibsrule88
      Frequent Visitor

      Thank you for your help.

       

      Correct , each time user goes out or move system creates a new record with new code with fixed QTY.

       

      best way is count the duplicates, based on dates and devide the fixed Qty on Count.

       

       

      Thank you

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Zaibsrule88 

     

    Please new a measure.

     

    Total =
    VAR _table =
        SUMMARIZE ( 'Table', 'Table'[Code], 'Table'[Date], 'Table'[AvailableCap] )
    VAR _total =
        SUMX ( _table, 'Table'[AvailableCap] )
    RETURN
        _total

     

    The PBIX file is attached for reference.

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

    • Zaibsrule88's avatar
      Zaibsrule88
      Frequent Visitor

      Thank you Anonymous 

       

      It solves the issue.

       

      Thank you