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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Aggregate by Measure and Chart Generation

Here is my source data:

andrewseaman_0-1597091842368.png

I also have two identical tables where I select a version:

andrewseaman_1-1597091992161.png

Now, I am doing a version to version comparison.  I select one Version_1 and one Version_2, then run a bunch of Delta calculations:

andrewseaman_2-1597092094678.png

 

andrewseaman_3-1597092104499.png

As an example Net_Amt_V1 is shown below:

andrewseaman_4-1597092155421.png

What I need help with is aggregating the Explanation column.

andrewseaman_5-1597092191561.png

I want to be able to filter on "DROP", "ADD", "CHANGE".  I also want to be able to create bar charts based on aggregating "Net Amt Delta" by the different Explanations.  Any ideas?

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

If you want to be able to filter on "DROP", "ADD", "CHANGE".

1. First create a new table as below.

explanation1.png

 

2. Write a measure. With this measure, you can filter a single value or multiple values at the same time.

Explanation =
VAR t =
    IF (
        [Net_Amt_V2] = 0
            && [Start_Month_V2] = 0
            && [End_Month_V2] = 0,
        "Drop",
        IF (
            [Net_Amt_V1] = 0
                && [Start_Month_V1] = 0
                && [End_Month_V1] = 0,
            "ADD",
            IF (
                [Net_Amt_V2] <> 0
                    && [Start_Month_V2] <> 0
                    && [End_Month_V2] <> 0
                    && [Net_Amt_V1] <> 0
                    && [Start_Month_V1] <> 0
                    && [End_Month_V1] <> 0,
                "CHANGE"
            )
        )
    )
RETURN
    SWITCH ( TRUE (), t IN VALUES ( Explanation[Explanation] ), t )

 

3. Set Explanation is not blank in Filters to Show items when the value is not blank.

explanation2.png

 

4. The result is as below with the Explanation slicer.

add.gif

 

 

If you want to be able to create bar charts based on aggregating "Net Amt Delta" by the different Explanations.

 

1. Write a measure as below.

Aggregate Net Amt Delta = 
CALCULATE (
    'Main'[Net Amt Delta],
    FILTER (
        VALUES ( Main[Product ID] ),
        'Main'[Explanation] = SELECTEDVALUE ( Explanation[Explanation] )
    )
)

 

2. The result is as below.

add2.gif

 

You can check more details from here.

 

 

Best Regards,

Icey

 

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

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Anonymous ,

 

If you want to be able to filter on "DROP", "ADD", "CHANGE".

1. First create a new table as below.

explanation1.png

 

2. Write a measure. With this measure, you can filter a single value or multiple values at the same time.

Explanation =
VAR t =
    IF (
        [Net_Amt_V2] = 0
            && [Start_Month_V2] = 0
            && [End_Month_V2] = 0,
        "Drop",
        IF (
            [Net_Amt_V1] = 0
                && [Start_Month_V1] = 0
                && [End_Month_V1] = 0,
            "ADD",
            IF (
                [Net_Amt_V2] <> 0
                    && [Start_Month_V2] <> 0
                    && [End_Month_V2] <> 0
                    && [Net_Amt_V1] <> 0
                    && [Start_Month_V1] <> 0
                    && [End_Month_V1] <> 0,
                "CHANGE"
            )
        )
    )
RETURN
    SWITCH ( TRUE (), t IN VALUES ( Explanation[Explanation] ), t )

 

3. Set Explanation is not blank in Filters to Show items when the value is not blank.

explanation2.png

 

4. The result is as below with the Explanation slicer.

add.gif

 

 

If you want to be able to create bar charts based on aggregating "Net Amt Delta" by the different Explanations.

 

1. Write a measure as below.

Aggregate Net Amt Delta = 
CALCULATE (
    'Main'[Net Amt Delta],
    FILTER (
        VALUES ( Main[Product ID] ),
        'Main'[Explanation] = SELECTEDVALUE ( Explanation[Explanation] )
    )
)

 

2. The result is as below.

add2.gif

 

You can check more details from here.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , You need to version table or at least one disconnected table. It will work the same way I have done it for dates in this blog

 

Refer:https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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