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

How to show Group Total with Lowest detailed data in report

Dear Folks,

 

I have a requirement where I have to show group total along with the detailed data.

 

Source tables:

DATA TABLE:

ojhassonu_3-1700120738977.png

 

MAPPING TABLE:

ojhassonu_1-1700119926598.png

 

REQUIRED OUTPUT:

ojhassonu_2-1700120697074.png

 

I tried measure below measure but couldn't worked.

total pillar wgt =
IF ( ISBLANK ( SUM (DATA[WEIGHT]) ), BLANK (),
CALCULATE ( SUM (DATA[WEIGHT]), REMOVEFILTERS (DATA[Metric]) ) )
 
Power BI file with sample data
 
please advise to achive the Total Weight for Pillar and show it as required output format.
 
Regards,
Sonu
5 REPLIES 5
ojhassonu
Frequent Visitor

Thanks for reply.

 

Please find below my actual requirement "Matrix format" screenshot. As in matrix, I'd like to show pillar weight next to Pillar column, can't add matrix. However tried with column but it doesn't work. I used the DAX and its showing same value for all.

pillarwtcol=
IF(NOT(ISBLANK(SELECTEDVALUE(MAPPING[PILLAR]))),
SUMX(FILTER(ALL(MAPPING), MAPPING[PILLAR] = SELECTEDVALUE(MAPPING[PILLAR])), SUMX(SUMMARIZE(FILTER(ALL(DATA), DATA[METRIC] = MAPPING[METRIC] ), DATA[METRIC], "Avg"AVERAGE(DATA[WEIGHT])), MAX([Avg]
))),
SUMX(SUMMARIZE(MAPPING, MAPPING[PILLAR]), AVERAGE(DATA[WEIGHT])))
 
and 
Pillar WeightCol =
SUMX(
    FILTER(ALL(MAPPING),
    MAPPING[PILLAR] = SELECTEDVALUE(MAPPING[PILLAR])
    ),
    SUMX(
        SUMMARIZE(
            FILTER(
            ALL(F_Data_Tabular),
            F_Data_Tabular[METRIC] = MAPPING[METRIC] ),
             F_Data_Tabular[METRIC],
            "Avg",
            AVERAGE(F_Data_Tabular[WEIGHT])
            ),
            MAX([Avg]
            )
            )
        )

 

 

ojhassonu_0-1700463675230.png

 

please advise.

TobyNye
Resolver II
Resolver II

Hi, I downloaded your sample pbix and built this measure which seems to work as you described:

TobyNye_0-1700126596116.png

 

The reason for the average in the SUMMARIZE function is because there were multiple rows per metric in your data table and your desired output had the average value, you can change that to whichever aggregation suits your needs if that's not what you want. The measure is effectively removing the row level filter context, putting it back on for the pillar, then going into the DATA table where the metric id's match and summing the sum of the average weight from the data table. Raw measure code:

Pillar Weight =
SUMX(FILTER(ALL(MAPPING), MAPPING[PILLAR] = SELECTEDVALUE(MAPPING[PILLAR])), SUMX(SUMMARIZE(FILTER(ALL(DATA), DATA[METRIC] = MAPPING[METRIC] ), DATA[METRIC], "Avg", AVERAGE(DATA[WEIGHT])), MAX([Avg]
)))
 
Hope that helps, let me know if you have any issues or further questions.

Great Thanks for the reply. This dax is almost working, however 

1. This is not showing Grand Total of pillar weight.

2. This DAX is not working in Matrix view, could you help me same as for calculated column. That would show grand total as well

 

Best Regards,

 

Could you show me the matrix or share a file with it where it's not working? I believe the issue will be related to exactly which fields from which table you are wanting to have within it. I imagine the measure will just need a few tweaks to fit your exact use case. The reason it returns blank on total is because it's looking for SELECTEDVALUES of pillar and metric in order to get the filter context we want at a row level. You could remedy this by adding an IF statement to the beginning such that your measure would look like:

Pillar Weight =
IF(NOT(ISBLANK(SELECTEDVALUE(MAPPING[PILLAR]))),
SUMX(FILTER(ALL(MAPPING), MAPPING[PILLAR] = SELECTEDVALUE(MAPPING[PILLAR])), SUMX(SUMMARIZE(FILTER(ALL(DATA), DATA[METRIC] = MAPPING[METRIC] ), DATA[METRIC], "Avg"AVERAGE(DATA[WEIGHT])), MAX([Avg]
))),
SUMX(SUMMARIZE(MAPPING, MAPPING[PILLAR]), AVERAGE(DATA[WEIGHT])))
 
If that doesn't work, let me know and I'll recreate the .pbix I had and give it another look.

Thanks for reply.

 

Please find below my actual requirement "Matrix format" screenshot. As in matrix, I'd like to show pillar weight next to Pillar column, can't add matrix. However tried with column but it doesn't work. I used the DAX and its showing same value for all.

pillarwtcol=
IF(NOT(ISBLANK(SELECTEDVALUE(MAPPING[PILLAR]))),
SUMX(FILTER(ALL(MAPPING), MAPPING[PILLAR] = SELECTEDVALUE(MAPPING[PILLAR])), SUMX(SUMMARIZE(FILTER(ALL(DATA), DATA[METRIC] = MAPPING[METRIC] ), DATA[METRIC], "Avg"AVERAGE(DATA[WEIGHT])), MAX([Avg]
))),
SUMX(SUMMARIZE(MAPPING, MAPPING[PILLAR]), AVERAGE(DATA[WEIGHT])))
 
and 
Pillar WeightCol =
SUMX(
    FILTER(ALL(MAPPING),
    MAPPING[PILLAR] = SELECTEDVALUE(MAPPING[PILLAR])
    ),
    SUMX(
        SUMMARIZE(
            FILTER(
            ALL(F_Data_Tabular),
            F_Data_Tabular[METRIC] = MAPPING[METRIC] ),
             F_Data_Tabular[METRIC],
            "Avg",
            AVERAGE(F_Data_Tabular[WEIGHT])
            ),
            MAX([Avg]
            )
            )
        )

 

 

ojhassonu_1-1700471505677.png

 

 

 

please advise.

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.