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
tvilla
New Member

Barchart with constant line

Hi everybody,

I'm stucked on this issue from a while and realized I need help to go further. 

 

I have two table with the follow headers:

1) ID, Date (yyyy-mm-dd), Type1, Type2, Value1

2) ID, Month(yyyy-mm-01), Value2

 

I would like to build a barchart with the follow features:

- the barchart shows the daily value1 for each ID in a specific month (both selectable through a filter)

- the barchart has a constant line showing value2 for the selected ID and month

- I need to allow filter by type1 and type2 (when a filter is selected the bar should go down while the constant line has to remain stable or disappear at all)

 

I hope you can help me with this task and wait for your feedback,

Thank you!

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @tvilla,

#1, You can refer to the following blog to create relationships based on multiple table fields. (create a calculated column with year, month part from the date field and concatenate with id, then extract them to create a bridge table with unique value to mapping two table records)

Relationship in Power BI with Multiple Columns - RADACAD

How to Join Many to Many with a Bridge Table in Power BI | Seer Interactive

#2, I'd like to suggest you create a measure formula to summary value based on current groups and use it as the constant line:

measure =
VAR selected =
    MAX ( Table1[Date] )
RETURN
    CALCULATE (
        SUM ( Table2[Value2] ),
        FILTER (
            ALLSELECTED ( Table2 ),
            YEAR ( [Date] ) = YEAR ( selected )
                && MONTH ( [Date] ) = MONTH ( selected )
        ),
        VALUES ( Table1[ID] )
    )

#3, You can try to do 'unpivot column' on type fields to send them to attribute and value, then you can simply use one filter to filter across multiple table fields.

Unpivot columns - Power Query | Microsoft Docs

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

HI @tvilla,

#1, You can refer to the following blog to create relationships based on multiple table fields. (create a calculated column with year, month part from the date field and concatenate with id, then extract them to create a bridge table with unique value to mapping two table records)

Relationship in Power BI with Multiple Columns - RADACAD

How to Join Many to Many with a Bridge Table in Power BI | Seer Interactive

#2, I'd like to suggest you create a measure formula to summary value based on current groups and use it as the constant line:

measure =
VAR selected =
    MAX ( Table1[Date] )
RETURN
    CALCULATE (
        SUM ( Table2[Value2] ),
        FILTER (
            ALLSELECTED ( Table2 ),
            YEAR ( [Date] ) = YEAR ( selected )
                && MONTH ( [Date] ) = MONTH ( selected )
        ),
        VALUES ( Table1[ID] )
    )

#3, You can try to do 'unpivot column' on type fields to send them to attribute and value, then you can simply use one filter to filter across multiple table fields.

Unpivot columns - Power Query | Microsoft Docs

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.