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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

DAX Calculation including 2 columns and slicer

Hello all, I am trying to write a DAX measure for my report where I have a table as shown below and need to show the Category and Subcategory which will be connected to my slicer. I have mentioned calculation and output required. Let me know, if more clarity is required. Thanks.

Input table

Ticket#CategorySubCategorySLA
Ticket 1AA-1Yes
Ticket 2BB-1Yes
Ticket 3BB-2No
Ticket 4BB-2No
Ticket 5AA-1No
Ticket 6AA-2No
Ticket 7BB-2No
Ticket 8BB-3Yes
Ticket 9BB-3Yes
Ticket 10BB-1No

 

 

calculation:

CategorySubCategoryTotal TicketsSLA = YESSLA%
AA-12150%
AA-2100%
BB-12150%
BB-2300%
BB-322100%

 

Output:

If Slicer selection is A then card visual should show

                         A -> A-1 50%

 

If Slicer selection is B then card visual should show

                      B -> B-3 100%

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
Here is a sample file with the solution https://www.dropbox.com/t/xUJUyAWUTD6YmKrI

1.png2.png

Measures are

 

Total Tickets = COUNTROWS ( Input )
SLA (YES) = CALCULATE ( COUNTROWS ( Input ), Input[SLA] = "Yes" )
SLA% = DIVIDE ( [SLA (YES)], [Total Tickets] )
CARD = 
VAR SummaryTable = 
    SUMMARIZE ( Input, Input[Category], Input[SubCategory] )
VAR MaximumSLAPercentage =
    MAXX ( 
        SummaryTable,
        [SLA%]
    )
VAR Result =
CONCATENATEX ( 
    FILTER ( 
        SummaryTable,
        [SLA%] = MaximumSLAPercentage
    ),
    Input[SubCategory] & " (" & FORMAT ( [SLA%], "#,#0.0%" ) & ")"
)
RETURN
    Result

 

 

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Anonymous 
Here is a sample file with the solution https://www.dropbox.com/t/xUJUyAWUTD6YmKrI

1.png2.png

Measures are

 

Total Tickets = COUNTROWS ( Input )
SLA (YES) = CALCULATE ( COUNTROWS ( Input ), Input[SLA] = "Yes" )
SLA% = DIVIDE ( [SLA (YES)], [Total Tickets] )
CARD = 
VAR SummaryTable = 
    SUMMARIZE ( Input, Input[Category], Input[SubCategory] )
VAR MaximumSLAPercentage =
    MAXX ( 
        SummaryTable,
        [SLA%]
    )
VAR Result =
CONCATENATEX ( 
    FILTER ( 
        SummaryTable,
        [SLA%] = MaximumSLAPercentage
    ),
    Input[SubCategory] & " (" & FORMAT ( [SLA%], "#,#0.0%" ) & ")"
)
RETURN
    Result

 

 

Anonymous
Not applicable

Thank you @tamerj1 , this is what I was looking for...

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Picture1.png

 

Total tickets: = 
COUNTROWS( Data )

 

SLA Yes: = 
CALCULATE ( [Total tickets:], Data[SLA] = "Yes" )

 

SLA Yes Ratio: =
IF (
    HASONEVALUE ( Data[SubCategory] ),
    DIVIDE ( [SLA Yes:], [Total tickets:] ),
    MAXX (
        ADDCOLUMNS (
            ALL ( Data[SubCategory] ),
            "@SLAYes", CALCULATE ( DIVIDE ( [SLA Yes:], [Total tickets:] ) )
        ),
        Data[SubCategory]
    ) & " "
        & FORMAT (
            MAXX (
                ADDCOLUMNS (
                    ALL ( Data[SubCategory] ),
                    "@SLAYes", CALCULATE ( DIVIDE ( [SLA Yes:], [Total tickets:] ) )
                ),
                [@SLAYes]
            ),
            "#,#0.0%"
        )
)


Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Anonymous
Not applicable

Thanks for the response, this works fine, only one issue, when I select Category "A" in slicer it is not showing "A1" as selected value instead it is showing B-3 for any selection.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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