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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Formatting dashboard with multiple filters

Hello all, 
I need your help formatting the dashboard specific way that I'm struggling with. Below are 2 tables that I'm using 

 

Table 1

SiteDateTypeSales
210/1/2024Coke50
109/30/2024Apple50
29/29/2024Apple125
19/29/2024Coke100
19/15/2024Pepsi500
29/1/2024Pepsi75
27/5/2024Coke75
16/30/2024Apple150
19/27/2024Pepsi200
29/30/2024Pepsi100
27/28/2024Apple225


Table2:

SiteApple_goalCoke_goalPepsi_goal
1212
23.51.5
    

Table 2 is the daily goals for those items. What I need to do is I need to first calculate goals for 7D, 30D, and 365D and bring them in along with the other columns so they are side by side and then calculate the different. See below the for the end result. Is this possible in PBI? Please help!! Below is what I'm trying to achieve.

 

 

SiteCokeCoke_GoalDiffPepsiPepsi_GoalDiffAppleApple_GoalDiff
1         
          7Day10079320014186501436
          30Day1003070700606405060-10
          365Day100365-265700730-30200730-530
2         
          7Day503.546.510010.589.512521104
          30Day50153510090101259035

          365Day

125182.5-57.5175547.5-372.53501095-745



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

 

You can try the following dax:

Bulk =
VAR _7day =
    TODAY () - 7
VAR _30day =
    TODAY () - 30
VAR _365day =
    TODAY () - 365
RETURN
    SWITCH (
        TRUE (),
        MAX ( 'Table'[Value] ) = "7Day",
            SUMX (
                FILTER (
                    ALL ( 'Table1' ),
                    'Table1'[Site] = MAX ( 'Table'[Site] )
                        && 'Table1'[Date] > _7day
                        && 'Table1'[Type] = "Apple"
                        && 'Table1'[Bulk] <> "False"
                ),
                [Sales]
            ),
        MAX ( 'Table'[Value] ) = "30Day",
            SUMX (
                FILTER (
                    ALL ( 'Table1' ),
                    'Table1'[Site] = MAX ( 'Table'[Site] )
                        && 'Table1'[Date] > _30day
                        && 'Table1'[Type] = "Apple"
                        && 'Table1'[Bulk] <> "False"
                ),
                [Sales]
            ),
        MAX ( 'Table'[Value] ) = "365Day",
            SUMX (
                FILTER (
                    ALL ( 'Table1' ),
                    'Table1'[Site] = MAX ( 'Table'[Site] )
                        && 'Table1'[Date] > _365day
                        && 'Table1'[Type] = "Apple"
                        && 'Table1'[Bulk] <> "False"
                ),
                [Sales]
            )
    )
Bulk_Goal =
VAR _7day =
    TODAY () - 7
VAR _30day =
    TODAY () - 30
VAR _365day =
    TODAY () - 365
VAR _switch =
    SWITCH (
        TRUE (),
        MAX ( 'Table'[Value] ) = "7Day", 7,
        MAX ( 'Table'[Value] ) = "30Day", 30,
        MAX ( 'Table'[Value] ) = "365Day", 365
    )
RETURN
    IF (
        MAX ( 'Table'[Site] ) = 1,
        _switch,
        SUMX (
            FILTER ( ALL ( 'Table2' ), 'Table2'[Site] = MAX ( 'Table'[Site] ) ),
            [Bulk_goal]
        ) * _switch
    )
Bulk_Diff =
[Bulk] - [Bulk_Goal]

vyangliumsft_0-1728548916894.png

 

 

Best Regards,

Liu Yang

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

3 REPLIES 3
Anonymous
Not applicable

Hi  @Anonymous ,

 

You can try the following dax:

Bulk =
VAR _7day =
    TODAY () - 7
VAR _30day =
    TODAY () - 30
VAR _365day =
    TODAY () - 365
RETURN
    SWITCH (
        TRUE (),
        MAX ( 'Table'[Value] ) = "7Day",
            SUMX (
                FILTER (
                    ALL ( 'Table1' ),
                    'Table1'[Site] = MAX ( 'Table'[Site] )
                        && 'Table1'[Date] > _7day
                        && 'Table1'[Type] = "Apple"
                        && 'Table1'[Bulk] <> "False"
                ),
                [Sales]
            ),
        MAX ( 'Table'[Value] ) = "30Day",
            SUMX (
                FILTER (
                    ALL ( 'Table1' ),
                    'Table1'[Site] = MAX ( 'Table'[Site] )
                        && 'Table1'[Date] > _30day
                        && 'Table1'[Type] = "Apple"
                        && 'Table1'[Bulk] <> "False"
                ),
                [Sales]
            ),
        MAX ( 'Table'[Value] ) = "365Day",
            SUMX (
                FILTER (
                    ALL ( 'Table1' ),
                    'Table1'[Site] = MAX ( 'Table'[Site] )
                        && 'Table1'[Date] > _365day
                        && 'Table1'[Type] = "Apple"
                        && 'Table1'[Bulk] <> "False"
                ),
                [Sales]
            )
    )
Bulk_Goal =
VAR _7day =
    TODAY () - 7
VAR _30day =
    TODAY () - 30
VAR _365day =
    TODAY () - 365
VAR _switch =
    SWITCH (
        TRUE (),
        MAX ( 'Table'[Value] ) = "7Day", 7,
        MAX ( 'Table'[Value] ) = "30Day", 30,
        MAX ( 'Table'[Value] ) = "365Day", 365
    )
RETURN
    IF (
        MAX ( 'Table'[Site] ) = 1,
        _switch,
        SUMX (
            FILTER ( ALL ( 'Table2' ), 'Table2'[Site] = MAX ( 'Table'[Site] ) ),
            [Bulk_goal]
        ) * _switch
    )
Bulk_Diff =
[Bulk] - [Bulk_Goal]

vyangliumsft_0-1728548916894.png

 

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

@Anonymous 

Hello,

 

First of all, thank you for taking the time to post on my board and assisting me with formatting my dashboard. Your solution worked perfect!! 

There is one additional change I wanted to make and see if you can help me figure this out.

Table 1

SiteDateTypeSalesBulk
210/1/2024Coke50False
109/30/2024Apple50True
29/29/2024Apple125False
19/29/2024Coke100False
19/15/2024Pepsi500False
29/1/2024Pepsi75False
27/5/2024Coke75False
16/30/2024Apple150False
19/27/2024Pepsi200False
29/30/2024Pepsi100False
27/28/2024Apple225True

 

SiteApple_goalCoke_goalPepsi_goalBulk_goal
1212.2
23.51.5.15
     

Here I have addeda column "Bulk" where it is only comparable to the Type "Apple".  I want to make 2 changes to what you sent me. 
1) I need to recalculate the Apple total with excluding where Bulk is "False"
2) I need to add another columns for only the Bulk Sales

Please see below for the final result.

SiteCokeCoke_GoalDiffBulkBulk GoalBulk Diff
1      
          7Day100793   
          30Day1003070   
          365Day100365-265   
2      
          7Day503.546.5   
          30Day501535   

          365Day

125182.5-57.5   
Anonymous
Not applicable

Hi  @Anonymous ,

 

When Site=1,Date=2024.9.30 there is no value in 7Days because it is less than Today()-7, I change the date of the data

vyangliumsft_0-1728439967414.png

You can use the CROSSJOIN() function to create a new table by joining [Site] of Table1 with “7Day”, “30Day”, “365Day”. Join to create a new table

 

Here are the steps you can follow:

1. Create calculated table.

Table =
var _table1=
{"7Day","30Day","365Day"}
var _table2=
DISTINCT('Table1'[Site])
RETURN
CROSSJOIN(
    _table2,_table1)

vyangliumsft_1-1728439967415.png

2. Create measure.

Coke =
var _7day=TODAY()-7
var _30day=TODAY()-30
var _365day=TODAY()-365
return
SWITCH(
    TRUE(),
    MAX('Table'[Value])="7Day",
    SUMX(
        FILTER(ALL('Table1'),
        'Table1'[Site]=MAX('Table'[Site])&&'Table1'[Date]>_7day&&'Table1'[Type]="Coke"),[Sales]),
     MAX('Table'[Value])="30Day",
    SUMX(
        FILTER(ALL('Table1'),
        'Table1'[Site]=MAX('Table'[Site])&&'Table1'[Date]>_30day&&'Table1'[Type]="Coke"),[Sales]),  
    MAX('Table'[Value])="365Day",
    SUMX(
        FILTER(ALL('Table1'),
        'Table1'[Site]=MAX('Table'[Site])&&'Table1'[Date]>_365day&&'Table1'[Type]="Coke"),[Sales]))
Coke_Goal =
var _switch=
SWITCH(
    TRUE(),
    MAX('Table'[Value])="7Day",7,
     MAX('Table'[Value])="30Day",30,  
    MAX('Table'[Value])="365Day",365)
return
IF(
    MAX('Table'[Site])=1,_switch
,
SUMX(
    FILTER(ALL('Table2'),'Table2'[Site]=MAX('Table'[Site])),[Coke_goal]) * _switch)
Coke_Diff =
 [Coke] - [Coke_Goal]

3. Result:

vyangliumsft_2-1728439997910.png

 

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.