cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Power BI Dynamic Grouping

I've a requirement on a Table to summarise the data based on below scenarios: The Table 1 is the existing, the Table 2 is what is expecting.

Table 1

Item#ItemNameReasonCatogeryLostSales
28783Item 1Orders waitingcat1$54
28783Item 1Short Term Out Of Stockcat1$13
28844Item 2Long Term Out of Stockcat 2$78
29193Item 3Orders waitingcat 3$15
30151Item 4Discontinuecat 4$302
30311Item 5Not applicablecat 5$64
30663Item 6Orders waitingcat 6$418

 

Table 2

Item#ItemNameReasonCatogeryLostSales
28783Item 1Mixedcat1$68
28844Item 2Long Term Out of Stockcat 2$78
29193Item 3Orders waitingcat 3$15
30151Item 4Discontinuecat 4$302
30311Item 5Not applicablecat 5$64
30663Item 6Orders waitingcat 6$418

 

 Any one help on this achieving the Table 2.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver I
Resolver I

Re: Power BI Dynamic Grouping

Hi,

 

You need to create measure like this:

 
Reason_new = 
var _Reason = LASTNONBLANK(Arkusz1[Reason];1)
RETURN
IF(
    CALCULATE( DISTINCTCOUNT(Arkusz1[Reason]) ;
    all(Arkusz1[Reason])) > 1
    ;"Mixed"
    ;_Reason
    )

This is solution for you.reason.PNG

 

 

 

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Power BI Dynamic Grouping

The only way I can think of for doing this would be to create a measure which you would use in place of the "Reason" attribute.

 

eg.

 

Reason Text = SELECTEDVALUE( 'Table 1'[Reason], "Mixed")

Highlighted
Resolver I
Resolver I

Re: Power BI Dynamic Grouping

Hi,

 

You need to create measure like this:

 
Reason_new = 
var _Reason = LASTNONBLANK(Arkusz1[Reason];1)
RETURN
IF(
    CALCULATE( DISTINCTCOUNT(Arkusz1[Reason]) ;
    all(Arkusz1[Reason])) > 1
    ;"Mixed"
    ;_Reason
    )

This is solution for you.reason.PNG

 

 

 

View solution in original post

Super User III
Super User III

Re: Power BI Dynamic Grouping

I'm not sure what behaviour you want when filters are applied via slicers that result in only 1 reason being present, but just note that @saykasku 's approach will always return "Mixed" regardless of any current filters, while the approach using SELECTEDVALUE() function will switch to showing the single reason if the current filter context eliminates the multiple reasons. Both approaches are valid, it just depends on what your requirements are.

 

eg

 

201908 mixed reason.gif

 

 

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors