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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
minseon
Frequent Visitor

add a category that is not in the table

Hi all

Is it possible to add a category that is not in the table?

 

i have data like below

minseon_0-1707359343678.png

 

and i want to display like below

A and B categories are month-to-date (MTD), and the C category is a fixed value regardless of the date slicer.

minseon_1-1707359377374.png

 

and result that i want is this

minseon_2-1707359491330.png

until now
1. user matrix chart -> row(categort), column(category2) 

2. i made dax that display mtd and monthly total

 

Using DAX, it is possible to implement something like the 3rd picture??

 

Thanks all 🙂

1 ACCEPTED SOLUTION
talespin
Solution Sage
Solution Sage

hi @minseon ,

 

This is a dirty solution, if it works for you. Better doing it in Power Query.

 

MTD Val =
VAR _Dt = SELECTEDVALUE(TestTbl5[Dt])
VAR _cat = SELECTEDVALUE( TestTbl5[Category])
VAR _cat2 = SELECTEDVALUE(TestTbl5[Category2])
VAR _Return = IF( _cat = "A" && _cat2 = "c", 100,
            IF( _cat = "B" && _cat2 = "c", 200,
                CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt )
            )
)

RETURN IF( HASONEFILTER(TestTbl5[Category]) && HASONEFILTER(TestTbl5[Category2]), _Return,
VAR _Aa = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "A", TestTbl5[Category2] = "a")
VAR _Ab = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "A", TestTbl5[Category2] = "b")
VAR _Ac = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "A", TestTbl5[Category2] = "c")
VAR _Ba = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "B", TestTbl5[Category2] = "a")
VAR _Bb = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "B", TestTbl5[Category2] = "b")
VAR _Bc = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "B", TestTbl5[Category2] = "c")
RETURN
IF( NOT(HASONEFILTER(TestTbl5[Category])) && HASONEFILTER(TestTbl5[Category2]),
        IF( _cat2 = "a", _Aa/_Ba,
            IF( _cat2 = "b", _Ab/_Bb,
                IF( _cat2 = "c", 100/200)
            )
        )
)
)
 
talespin_1-1707390044442.png

 


 

View solution in original post

1 REPLY 1
talespin
Solution Sage
Solution Sage

hi @minseon ,

 

This is a dirty solution, if it works for you. Better doing it in Power Query.

 

MTD Val =
VAR _Dt = SELECTEDVALUE(TestTbl5[Dt])
VAR _cat = SELECTEDVALUE( TestTbl5[Category])
VAR _cat2 = SELECTEDVALUE(TestTbl5[Category2])
VAR _Return = IF( _cat = "A" && _cat2 = "c", 100,
            IF( _cat = "B" && _cat2 = "c", 200,
                CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt )
            )
)

RETURN IF( HASONEFILTER(TestTbl5[Category]) && HASONEFILTER(TestTbl5[Category2]), _Return,
VAR _Aa = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "A", TestTbl5[Category2] = "a")
VAR _Ab = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "A", TestTbl5[Category2] = "b")
VAR _Ac = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "A", TestTbl5[Category2] = "c")
VAR _Ba = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "B", TestTbl5[Category2] = "a")
VAR _Bb = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "B", TestTbl5[Category2] = "b")
VAR _Bc = CALCULATE( [SumVal], TestTbl5[Dt] <= _Dt, TestTbl5[Category] = "B", TestTbl5[Category2] = "c")
RETURN
IF( NOT(HASONEFILTER(TestTbl5[Category])) && HASONEFILTER(TestTbl5[Category2]),
        IF( _cat2 = "a", _Aa/_Ba,
            IF( _cat2 = "b", _Ab/_Bb,
                IF( _cat2 = "c", 100/200)
            )
        )
)
)
 
talespin_1-1707390044442.png

 


 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors