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

All the dim table column values are appearing when I add few measures to Table visual

I have to calculate categories for Previous year sales. My data is as follow:
Fact Table:

Geo KeyPartner IDSalesYear
565APJ61401,266.90YTD-1
USNA34021,728.22YTD
USNA34025,667.01YTD-1
USNA34550YTD
USNA34552,373.55YTD-1
USNA35211,517.19YTD
USNA35213,330.48YTD-1
USNA37852,256.53YTD-1

Dim Table:

dim_keyRegion
565APJASIA PACIFIC
USNAAMERICAS
409EMEA

EMEA

Relationship from Fact to Dim is Many to One.

Previous year sales measure is as follows:

PY sales = CALCULATE(

CALCULATE(Sum(Fact[Sales]),  FILTER('Fact','Fact'[Year] = "YTD-1"))
Category is if the  [PY sales] <=1000, then "A", [PY sales] >1000 && [PY sales] <=5000 then "B" else "C"
PY Category = 
SWITCH(
    TRUE(),
    [PY sales] <= 1000 , "A",
    [PY sales] > 1000 && [PY sales] <= 5000, "B", "C")
When I add these 2 measures along with Region column from Dim table, all the values from region values are appearing with blank PY sales.
Partner IDRegionPY SalesPY Category
3402AMERICAS5,667.01C
3402ASIA PACIFIC A
3402EMEA A
3455AMERICAS2,373.55B
3455ASIA PACIFIC A
3455EMEA A
3521AMERICAS3,330.48B
3521ASIA PACIFIC A
3521EMEA A

My Expected result should be like below:
Partner IDRegionPY SalesPY Category
3402AMERICAS5,667.01C
3455AMERICAS2,373.55B
3521AMERICAS3,330.48B
Kindly help to create the PY Category.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

Thanks for the solution @amitchandak  offered, and i want to offer some more information for user to refer to.

hello @anushak2207 , you just need to change your PY Category to the following.

PY Category =
IF (
    [PY sales] <> BLANK (),
    SWITCH (
        TRUE (),
        [PY sales] <= 1000, "A",
        [PY sales] > 1000
            && [PY sales] <= 5000, "B",
        "C"
    )
)

Output

vxinruzhumsft_0-1730081169641.png

Best Regards!

Yolo Zhu

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,

Thanks for the solution @amitchandak  offered, and i want to offer some more information for user to refer to.

hello @anushak2207 , you just need to change your PY Category to the following.

PY Category =
IF (
    [PY sales] <> BLANK (),
    SWITCH (
        TRUE (),
        [PY sales] <= 1000, "A",
        [PY sales] > 1000
            && [PY sales] <= 5000, "B",
        "C"
    )
)

Output

vxinruzhumsft_0-1730081169641.png

Best Regards!

Yolo Zhu

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

 

Thank You so much! This solution worked for me.

amitchandak
Super User
Super User

@anushak2207 , YTD and YTD -1 are values in table, then better have them in DIM , then it work better

 

like

 

PY sales = CALCULATE(
CALCULATE(Sum(Fact[Sales]), FILTER(all('Year'),'Year'[Year] = "YTD-1"))

 

then this should work

PY Category =
SWITCH(
TRUE(),
[PY sales] <= 1000 , "A",
[PY sales] > 1000 && [PY sales] <= 5000, "B", "C")

if you want to group by A, B, C, refer segmentation

 

Also refer

Power BI ABC Analysis using Window function, Dynamic Segmentation: https://youtu.be/A8mQND2xSR4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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!

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.

Top Solution Authors