Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

summarize by site did not return correct results

With Reference to the thread here ,I am expainging another issue I am facing currently and unable to get it to fix inspite of including Site[SiteID] in the summarize().

https://community.powerbi.com/t5/Developer/dax-measure-to-calculate-number-of-tickets-open-at-EOM-wi...

 

My measure:

CALCULATE(sumx(ADDCOLUMNS(SUMMARIZE(Int_New, 'Date'[Year], 'Date'[Month]), "MonthlyTotal", CALCULATE(DISTINCTCOUNT(Internal[ID])) - CALCULATE(DISTINCTCOUNT(Internal[ID]), USERELATIONSHIP('Date'[Date], Int_New[CloseDate]))), [MonthlyTotal]), FILTER(ALLselected('Date'[Date]), 'Date'[Date]<=EOMONTH(max('Internal'[OpenDate]), 0)))

 

Folliwing the above,i could obtain the correct aggregated values for per month and year,but when i bring in Site column from Site dimension(like below),i get values.

CALCULATE(sumx(ADDCOLUMNS(SUMMARIZE(Int_New, 'Date'[Year], 'Date'[Month],Sites[SiteID]), "MonthlyTotal", CALCULATE(DISTINCTCOUNT(Internal[ID])) - CALCULATE(DISTINCTCOUNT(Internal[ID]), USERELATIONSHIP('Date'[Date], Int_New[CloseDate]))), [MonthlyTotal]), FILTER(ALLselected('Date'[Date]), 'Date'[Date]<=EOMONTH(max('Internal'[OpenDate]), 0)))

 

I am not sure why this is happening and would like to slice by Site.

Below is the sample Internal fact table and Site dimension table.EOM.PNG

 

Sites.PNG

 

 Slicing by SiteID giving wrong results-

 

eom_prbl2.PNG                                       Also,when i bring in SiteID in the summarize(),I get wrong OpenFinal like below:

eom_prbl4.PNG                                                      Following is the correct output:

 

expected_eom.PNG

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks Dale,the solution to it is as follows:

Create 3 measure as below-

  • Measure1:  CALCULATE(DISTINCTCOUNT(Internal[Id]), FILTER(all('Date'[Date]), 'Date'[Date]<=max('Date'[Date])))
  • Measure2:      VAR maxDate =
        MAX ( 'Date'[Date] ) + 1
    RETURN
        CALCULATE (
            DISTINCTCOUNT ( Internal[Id] ),
            FILTER (
                ALL ( 'Date'[Date] ),
                'Date'[Date] <= maxDate
                    && 'Date'[Date] <> BLANK ()
            ),
            USERELATIONSHIP ( 'Date'[Date], Internal[CloseDate] )
        ) 
  • Measure3: [Measure1]-[Measure2]

 

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Thanks Dale,the solution to it is as follows:

Create 3 measure as below-

  • Measure1:  CALCULATE(DISTINCTCOUNT(Internal[Id]), FILTER(all('Date'[Date]), 'Date'[Date]<=max('Date'[Date])))
  • Measure2:      VAR maxDate =
        MAX ( 'Date'[Date] ) + 1
    RETURN
        CALCULATE (
            DISTINCTCOUNT ( Internal[Id] ),
            FILTER (
                ALL ( 'Date'[Date] ),
                'Date'[Date] <= maxDate
                    && 'Date'[Date] <> BLANK ()
            ),
            USERELATIONSHIP ( 'Date'[Date], Internal[CloseDate] )
        ) 
  • Measure3: [Measure1]-[Measure2]

 

v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

Try this formula, please.

Measure 3 =
CALCULATE (
    SUMX (
        ADDCOLUMNS (
            SUMMARIZE ( Internal, 'Date'[Date].[Year], 'Date'[Date].[Month] ),
            "MonthlyTotal", CALCULATE ( DISTINCTCOUNT ( Internal[ID] ) )
                - CALCULATE (
                    DISTINCTCOUNT ( Internal[ID] ),
                    USERELATIONSHIP ( 'Date'[Date], Internal[CloseDate] )
                )
        ),
        [MonthlyTotal]
    ),
    FILTER (
        ALLSELECTED ( 'Date' ),
        'Date'[Date] <= EOMONTH ( MAX ( 'Internal'[OpenDate] ), 0 )
    )
)

summarize_by_site_did_not_return_correct_results

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Dale,

I am using exactly the same formula as below but somehow the values grouped by Sites filtered are not giving correct numbers.

For excample,for Jan 2017 ,total open incidents are 11 but the graph and table just talk about 3 open with Site 2.What about the rest of the incidents.Below is the problem:

slice1.PNG

We need to first group the incidents by Year and Month ,and then group meausre by Site.I am using the same calculation as yours:

Open_final = CALCULATE(sumx(ADDCOLUMNS(SUMMARIZE(Internal,'Date'[Year],'Date'[Month]),"MonthlyTotal", CALCULATE(DISTINCTCOUNT(Internal[ID])) - CALCULATE(DISTINCTCOUNT(Internal[ID]), USERELATIONSHIP('Date'[Date], Internal[CloseDate]))),[MonthlyTotal]),FILTER(ALLselected('Date'[Date]), 'Date'[Date]<=EOMONTH(max('Internal'[OpenDate]), 0)))

 

In my real data,I see the following issue and it is wrong because the total for Jan 2018 says 49(correct-5+18+26) but when you group by and drag the Site,the numbers for detail levels are not correct.PBI.png

 

In short,pls help me replicate the same functionality available with the following custom table in tabular model without having to create calculated table and suing available date/Location dim-

End of Month =

SELECTCOLUMNS(

FILTER(

    CROSSJOIN(

        ADDCOLUMNS(

        FILTER(

            CALENDAR("2017-01-01",TODAY()),

            day([Date])=1

            ),

            "Reporting Month",var d = [Date]-1 RETURN DATE(YEAR(d),MONTH(d),1)

           

            ),

        'Table'),

        [Date] > [OpenedDate] &&

        [Date] < IF([CloseDate] = BLANK(),"2099-01-01",[CloseDate])

        ) ,

        "Month" , [Month] ,

        "ID" , [IncidentId],

        "Site", [SiteID]

)

 

 

 

Hi @Anonymous,

 

Based your sample data, it's 2 actually. 

summarize_by_site_did_not_return_correct_results2

 

The formula isn't the one I posted.

Open_final =
CALCULATE (
    SUMX (
        ADDCOLUMNS (
            SUMMARIZE ( Internal, 'Date'[Year], 'Date'[Month] ),
            "MonthlyTotal", CALCULATE ( DISTINCTCOUNT ( Internal[ID] ) )
                - CALCULATE (
                    DISTINCTCOUNT ( Internal[ID] ),
                    USERELATIONSHIP ( 'Date'[Date], Internal[CloseDate] )
                )
        ),
        [MonthlyTotal]
    ),
    FILTER (
        ALLSELECTED ( 'Date'[Date] ),
        'Date'[Date] <= EOMONTH ( MAX ( 'Internal'[OpenDate] ), 0 )
    )
)

Please check out and try again.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Dale,

I tried your new formula too,but the issue is not by applying Site filter.It comes down to when i just darg in SiteID into the table,why doesnt it show all 11 IDs for 2017 Jan.Why does it just show Jan 2017,Site 2 like below:-

slice1.PNG

Hi @Anonymous,

 

It seems I have made things complicated. Try this formula, please.

Open_final =
VAR minDate =
    CALCULATE ( MIN ( Internal[OpenDate] ), ALL ( Internal ) )
RETURN
    CALCULATE (
        SUMX ( Internal, CALCULATE ( DISTINCTCOUNT ( Internal[ID] ) ) )
            - CALCULATE (
                SUMX ( Internal, CALCULATE ( DISTINCTCOUNT ( Internal[ID] ) ) ),
                USERELATIONSHIP ( 'Date'[Date], Internal[CloseDate] )
            ),
        FILTER (
            ALL ( 'Date'[Date] ),
            'Date'[Date] <= MAX ( 'Date'[Date] )
                && 'Date'[Date] >= minDate
        )
    )

summarize_by_site_did_not_return_correct_results3

 

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

What is the difference between ID and Site ID.  Please describe the business question and your data.  Also, show the expected result.  Share data in a format that can be pasted in an Excel file.  


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Ashish,'

ID is incident# and SiteID is site ID.Samples and expected results are already posted.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.