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
Paulompm
Frequent Visitor

percentage of grand total with condition

Hello

I have a question about dax formulas. My data is distributed as follows:

 

 

product lineSubgroup$
line 1x10
line 1a200
line 1y100
line 2z200
line 2w1000
line 3m400
line 3f500
line 3p500
line 4o300
line 4k100
line 4r800

 

The column product line can be repeated. The subgroup column does not repeat itself.

My goal is to find the percentage of the subgroup just for the same product line. Example:

 

 

product lineSubgroup$%Grand Total by subgroup
line 1x103,23%
line 1a20064,52%
line 1y10032,26%
line 2z20016,67%
line 2w100083,33%
line 3m40028,57%
line 3f50035,71%
line 3p50035,71%
line 4o30025,00%
line 4k1008,33%
line 4r80066,67%
TOTAL 4110400,00%

 

 

If you look at the total percentage is 400% because each product line is individualized by subgroup.

 I would also like to know if there is a way to elect the subgroups that make 80% of my revenue(pareto analysis).

 

Thanks for the attention.

1 ACCEPTED SOLUTION

@Paulompm

 

Hi, made a little adjustment to Code and Try it (in Bold)

 

% of SubGroup in LineA =
IF (
    HASONEVALUE ( Table3[product line] ),
    DIVIDE (
        SUM ( Table3[$] ),
        CALCULATE (
            SUM ( Table3[$] ),
            ALLEXCEPT ( 'Table3', Table3[product line] ),
            VALUES ( 'Calendar'[Date] )
        )
    ),
    1 * DISTINCTCOUNT ( Table3[product line] )
)



Lima - Peru

View solution in original post

6 REPLIES 6
Vvelarde
Community Champion
Community Champion

@Paulompm

 

Hi, you can obtain using this DAX

 

% of SubGroup in Line =
IF (
    HASONEVALUE ( Table1[product line] ),
    DIVIDE (
        SUM ( Table1[$] ),
        CALCULATE ( SUM ( Table1[$] ), ALLEXCEPT ( Table1, Table1[product line] ) )
    ),
    1 * DISTINCTCOUNT ( Table1[product line] )
)

 

AExcept.png 




Lima - Peru

Thanks for your response. The formula works perfectly. But I would like to ask a new question. I have created a relation of this table with a classic calendar. When filter months and years the percentage does not work properly. Do I have to change anything?

@Paulompm

 

Show me what is the result and the expected result

 

 




Lima - Peru

@Vvelarde here is the sample again:

 

Dateproduct lineSubgroup$
02/05/2017line 1x10
10/05/2017line 1a200
05/06/2016line 1y100
04/05/2017line 2z200
07/05/2017line 2w1000
08/06/2016line 3m400
03/05/2017line 3f500
12/05/2017line 3p500
13/06/2016line 4o300
05/06/2016line 4k100
05/05/2017line 4r800

 

Result with the filter:

 

Result.jpg

 

 

 

 

 

 

 

 

 

 

 

expected result:

 

expected.jpg

 

@Paulompm

 

Hi, made a little adjustment to Code and Try it (in Bold)

 

% of SubGroup in LineA =
IF (
    HASONEVALUE ( Table3[product line] ),
    DIVIDE (
        SUM ( Table3[$] ),
        CALCULATE (
            SUM ( Table3[$] ),
            ALLEXCEPT ( 'Table3', Table3[product line] ),
            VALUES ( 'Calendar'[Date] )
        )
    ),
    1 * DISTINCTCOUNT ( Table3[product line] )
)



Lima - Peru

Thank you. Worked perfectly!

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.