Forum Discussion

kh4hk's avatar
kh4hk
Regular Visitor
8 years ago
Solved

Not able to aggregate data into unique categories

I am looking to aggregate all values greater than 2 months under "3+ Months Ago" however when I put the result in a visual the value "3+ Months Ago" appears multiple times, one per each value of the Var MthSince greater than 2.
 
Later I realized this behavior is not limited to "3+ Months Ago" but all categories.
 
Need help to fix it, thank you in advance.
 
Months Since Update =
VAR MthSince =
    DATEDIFF ( 'T360-Matters'[Last Update Date], TODAY (), MONTH )
RETURN
    SWITCH (
        MthSince,
        0, "This Month",
        1, "Last Month",
        2, "2 Months Ago",
        "3+ Months Ago"
    )
 
Here is result in table visual, 
 
  • Hi kh4hk,

     

    Could you post your table structures with some sample/mock data and the expected result, so that we can better assist on this issue?

     

    It's better to just share a dummy pbix file which can reproduce the issue. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. :smileyhappy:

     

    Regards

2 Replies

  • v-ljerr-msft's avatar
    v-ljerr-msft
    Microsoft Employee

    Hi kh4hk,

     

    Could you post your table structures with some sample/mock data and the expected result, so that we can better assist on this issue?

     

    It's better to just share a dummy pbix file which can reproduce the issue. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. :smileyhappy:

     

    Regards

    • kh4hk's avatar
      kh4hk
      Regular Visitor

      I was trying to annonymize the data to share it with you and solved the issue in doing so.

       

      The sorter formula was not aligned with Month Since Update column I shared earlier.

       

      (Before update) Month Since Update Sort = DATEDIFF ( 'T360-Matters'[Last Update Date], TODAY (), MONTH )

      (After update) Month Since Update Sort = Var MthSince = DATEDIFF('T360-Matters'[Last Update Date], TODAY(), MONTH) Return IF(MthSince=0,0,IF(MthSince=1,1, IF(MthSince=2, 2, 3)))

       

      Thank you so much for guiding me in right direction, appreciate your help.