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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
dedelman_clng
Community Champion
Community Champion

totals for products of measures, multiple contexts (DAX help)

This one is complicated, so please bear with me.  To start I have a complex data model due to having a few many-to-many relationships that need to be resolved

01 - Model.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The main fact table is "IT Outages", but

- one outage can affect multiple CIs, and one CI can have multiple outages (hence, Outage CI)

- one CIs can affect multiple applications, and one application is served by multiple CIs (hence, CIA)

 

I can calculate a single event total outage by taking the single outage duration and multiplying by the number of apps that were effected:

 

Total App Outage = 
CALCULATE (
    CALCULATE (
        SUM ( 'IT Outages'[Business Time] ),
        'Outage CI',
        NOT ( 'IT Outages'[Exclude] )
    ),
    CIA
)
Total Apps Affected = 
CALCULATE (
    CALCULATE (
        COUNTROWS ( VALUES(CIA[Application] )
    ),
    FILTER('Outage CI', NOT ( RELATED('IT Outages'[Exclude] )))
))
Total Outage = [Total App Outage] * [Total Apps Affected]

This works well for each point in time, but not in aggregate.  [Total Outage], when not filtered by Date, give a much higher number than it should.  Same with the following formula (which is basically the DAX for the first 2 measures replicated into a single code):

 

Running Downtime = 
TOTALYTD(
 CALCULATE (
    CALCULATE (
        SUM ( 'IT Outages'[Business Time] ),
        'Outage CI',
        NOT ( 'IT Outages'[Exclude] )
    ),
    CIA
) * 
 CALCULATE (
    CALCULATE (
        COUNTROWS ( VALUES(CIA[Application] )
    ),
    FILTER('Outage CI', NOT ( RELATED('IT Outages'[Exclude] )))
)),
 DateTab[Date])+0

I have tried to summarize the data below. Yellow is a wrong value, green is correct. The far right column is the expected result.

 

02 - excel.PNG

 

 

 

 

 

 

 

 

Essentially I'm trying to do the summation over a product of two measures.

 

Any assistance would be appreciated.

 

Thanks,

David Edelman

 

ETA: Sample data provided in a reply below

2 ACCEPTED SOLUTIONS
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @dedelman_clng,

 

I could not test your measures with the provided sample data, as column [Exclude] cannot be found in table 'IT Outages'.

 

Please try to create measures like below:

Total Outage = [Total App Outage] * [Total Apps Affected]

Total Outage2=sumx('IT Outages',[Total Outage])

 

Running Downtime =
CALCULATE (
    [Total Outage],
    FILTER (
        ALLSELECTED ( 'IT Outage' ),
        'IT Outage'[Date] <= MAX ( 'IT Outage'[Date] )
    )
)

 

Best regards,

Yuliana Gu

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

View solution in original post

Hi @v-yulgu-msft

 

The code you gave me got me in the right direction.  I also needed to have any day without an outage show the current YTD total, so I added another CALCULATE around the date table:

 

Running Down Time =
CALCULATE (
    CALCULATE (
        [Total Outage 2],
        FILTER (
            ALL ( 'IT Outages' ),
            'IT Outages'[Date of Outage] <= MAX ( 'IT Outages'[Date of Outage] )
        )
    ),
    FILTER ( ALL ( DateTab ), DateTab[Date] <= MAX ( DateTab[Date] ) )
)

Thanks!

David

View solution in original post

5 REPLIES 5
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @dedelman_clng,

 

I could not test your measures with the provided sample data, as column [Exclude] cannot be found in table 'IT Outages'.

 

Please try to create measures like below:

Total Outage = [Total App Outage] * [Total Apps Affected]

Total Outage2=sumx('IT Outages',[Total Outage])

 

Running Downtime =
CALCULATE (
    [Total Outage],
    FILTER (
        ALLSELECTED ( 'IT Outage' ),
        'IT Outage'[Date] <= MAX ( 'IT Outage'[Date] )
    )
)

 

Best regards,

Yuliana Gu

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

Hi @v-yulgu-msft

 

The code you gave me got me in the right direction.  I also needed to have any day without an outage show the current YTD total, so I added another CALCULATE around the date table:

 

Running Down Time =
CALCULATE (
    CALCULATE (
        [Total Outage 2],
        FILTER (
            ALL ( 'IT Outages' ),
            'IT Outages'[Date of Outage] <= MAX ( 'IT Outages'[Date of Outage] )
        )
    ),
    FILTER ( ALL ( DateTab ), DateTab[Date] <= MAX ( DateTab[Date] ) )
)

Thanks!

David

@v-yulgu-msft -

 

Apologies for leaving out the code.  Here it is below.  I will try your suggestion as well and report back.

 

Exclude = IF('IT Outages'[Business Impact] = "false", TRUE(), FALSE())

David

dedelman_clng
Community Champion
Community Champion

Sample data (date is a standard CALENDAR table) :

 

IT Outages:

TitleDescription of OutageDate of OutageTotal TimeBusiness TimeBusiness ImpactE&C ImpactAffected System
49Outage 11/30/20181515TRUETRUEServer
50Outage 24/26/201833TRUEFALSENetwork
51Outage 34/24/20181818TRUETRUENetwork
52Outage 45/12/2018720720FALSEFALSEServer
53Outage 55/21/20181717TRUETRUENetwork
54Outage 65/31/201868181TRUETRUENetwork
55Outage 76/8/201855TRUEFALSENetwork
56Outage 86/21/20183535TRUEFALSEServer
57Outage 96/25/20187272TRUEFALSEServer
58Outage 107/6/2018508508TRUEFALSEServer
59Outage 117/10/20181616TRUETRUENetwork

 

Outage CI

TitleAffected CI(s)
49CI29
50CI56
51CI56
52CI22
52CI40
53CI40
54CI22
54CI40
55CI22
56CI18
57CI11
57CI18
57CI19
58CI32
59CI28

 

CI

Infrastructure InstanceSLA Type
CI11SLA11
CI18SLA18
CI19SLA19
CI22SLA22
CI28SLA28
CI29SLA29
CI32SLA32
CI40SLA40
CI56SLA56

 

CIA

ApplicationInfrastructure Instance
App1CI40
App2CI40
App3CI28
App3CI29
App4CI22
App5CI32
App5CI40
App6CI18
App6CI19
App6CI40
App7CI40
App8CI11
App8CI40
App9CI40
App10CI40
App11CI40
App12CI40
App13CI40
App14CI22
App14CI40
App14CI56
App15CI40
App16CI22
App16CI40
Greg_Deckler
Super User
Super User

Sample data that can be copied and pasted would help tremendously. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said...This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.