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
Joe_100
Helper I
Helper I

Filter on slicer but select whole month

Hi all,

 

 

Please see the table below

PeriodSalesBudgetMonth YearHalfPeriod
012018P11015120181
012018P21520120182
022018P11422220181
022018P21413220182
032018P11315320181
032018P22115320182
042018P11110420181
042018P21920420182

 

I have a slicer on report period. If i select for example report period 032018P1 i get the full month budget with the following DAX (summing both periods in the month)

 

Budget Sum =
VAR myperiod =
    SELECTEDVALUE ( Table1[Month ] )
RETURN
    CALCULATE (
        SUM ( Table1[Budget] ),
        Table1[Month ] = myperiod,
        ALL ( Table1[Period] )
    )

 Now i have to split the budget in Period 1 and Period 2, even if i select only one period in the month.

So i had the idea to create two measures Period 1 and Period 2 use the same dax as above and then use a filter function to filter on HalfPeriod.

 

Somehow i can't seem to get it working....How can i add a filter to the dax expression above?

 

Thanks!

1 ACCEPTED SOLUTION

Hi all,

 

Your advise defenitely helped.

 

I now created the following DAX and seems to work (two times off course, period 1 and 2)

Thanks!

 

 

Period2 =
VAR myperiod =
SELECTEDVALUE (Table1[Month ])
var myyear =
SELECTEDVALUE(Table1[Year])
RETURN
CALCULATE (
SUM ( Table1[Budget]);
Table1[Month ] = myperiod;
Table1[Year] = myyear;
ALL ( Table1[Period] );
Table1[HalfPeriod] = 2)

View solution in original post

3 REPLIES 3
LivioLanzo
Solution Sage
Solution Sage

Try like this:

 

 

PeriodOneSales =
CALCULATE (
    SUM ( Sales[Sales] ),
    ALL ( Periods[Period] ),
    VALUES ( Periods[Month ] ),
    VALUES ( Periods[Year] ),
    Periods[HalfPeriod] = 1
)

 

PeriodTwoSales =
CALCULATE (
    SUM ( Sales[Sales] ),
    ALL ( Periods[Period] ),
    VALUES ( Periods[Month ] ),
    VALUES ( Periods[Year] ),
    Periods[HalfPeriod] = 2
)

 

Capture.PNG

 

 

Capture.PNG

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Hi all,

 

Your advise defenitely helped.

 

I now created the following DAX and seems to work (two times off course, period 1 and 2)

Thanks!

 

 

Period2 =
VAR myperiod =
SELECTEDVALUE (Table1[Month ])
var myyear =
SELECTEDVALUE(Table1[Year])
RETURN
CALCULATE (
SUM ( Table1[Budget]);
Table1[Month ] = myperiod;
Table1[Year] = myyear;
ALL ( Table1[Period] );
Table1[HalfPeriod] = 2)

Greg_Deckler
Super User
Super User

Hmm, not sure why the ALL clause exists but I would think that it should be:

 

Budget Sum P1 =
VAR myperiod =
    SELECTEDVALUE ( Table1[Month ] )
RETURN
    CALCULATE (
        SUM ( Table1[Budget] ),
        Table1[Month ] = myperiod && Table1[HalfPeriod]=1
    )


Budget Sum P2 =
VAR myperiod =
    SELECTEDVALUE ( Table1[Month ] )
RETURN
    CALCULATE (
        SUM ( Table1[Budget] ),
        Table1[Month ] = myperiod && Table1[HalfPeriod]=2
    )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.