Forum Discussion

Emerald70's avatar
Emerald70
Frequent Visitor
1 year ago
Solved

calculated accumulated values by quarter

DocumentDateQuarter
Doc11/22/2023Q1-2023
Doc12/11/2023Q1-2023
Doc23/12/2023Q1-2023
Doc34/13/2023Q2-2023
Doc45/14/2023Q2-2023
Doc46/15/2023Q2-2023
Doc410/16/2023Q3-2023
Doc411/17/2023Q3-2023
Doc412/18/2023Q3-2023
Doc10010/16/2022Q3-2022
Doc10011/17/2022Q3-2022
Doc10012/18/2022Q3-2022
Doc454512/18/2022Q3-2022

I have a quarter slicer  selection and I dont have a date  and to calculate the 
KPI : no of unique docs from the year 2022 to selected quarter
Example:   if I select the Q2-2023 on the slicer,    then the no of unique documents to be calculated from 2022 to 2023
output is :   6
Please help me to write a dax ?

 

  • Gabry's avatar
    Gabry
    1 year ago

    I think you might have done some mistake. Did you adjusted the measure to get the correct value of the slicer?

     

    Here is the pbix.

    If you still can't solve the issue, attach your pbix, I'll take a look

5 Replies

  • Gabry's avatar
    Gabry
    Icon for Super User rankSuper User

    Hello Emerald70 ,

     

    Measure = 
    Var _slicer = selectedvalue('Table'[Quarter])
    var _maxdate= Calculate (max('Table'[Date]), 'Table'[Quarter] = _slicer, all('Table'))
    return
    
    calculate(DISTINCTCOUNT('Table'[Document]), 'Table'[Date]<=_maxdate, all('Table'))

     

     

    Let me know if this help

      • Gabry's avatar
        Gabry
        Icon for Super User rankSuper User

        Why? I tested it and it works



        You have to check if data column is date data type.
        Also you asked to distinct count the documents, so to me it works as you asked. Let me know

  • Emerald70's avatar
    Emerald70
    Frequent Visitor

    it is date type only but still does not show the right result, because whatever the quarter I select it gives the same output as 6,  if I select Q3-2022 then it should give 2 but it gives 6 ,could you share your PBI file 

    • Gabry's avatar
      Gabry
      Icon for Super User rankSuper User

      I think you might have done some mistake. Did you adjusted the measure to get the correct value of the slicer?

       

      Here is the pbix.

      If you still can't solve the issue, attach your pbix, I'll take a look