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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
IAA
Helper I
Helper I

Dax slicer multiple selections

Dear Community,

I am building a cashflow forecast, where the due date of bills can dynamically changed with an X number of days, using a parameter. This is combined with a slicer where the specific cost category can be selected. The due date for that specific category can be extended when this category is selected.

I arranged this with the following formula:

 

 

 

 

Measure = 
 IF(ALLSELECTED('Slicer Table'[Category]) in FILTERS('Value by date 2'[Category]),
 CALCULATE  (SUM( 'Value by date 2'[Value] ) , DATEADD(DimDate[Date],-[Value Parameter],DAY)), 
 CALCULATE  (sum('Value by date 2'[Value]) , DATEADD(DimDate[Date],0,DAY)))

 

 

 

 

This works perfect, but the problem is that there is an error when I select multiple categories at the same time:

IAA_0-1596098730023.pngIAA_1-1596098779353.png


The error says:  a table of multiple of values was supplied where a single value was expected.

Can someone give some advice how to adjust my DAX-formula to make it possible to select multiple items?

If it helps, the PBIX file can be downloaded here:
https://www.dropbox.com/s/nfuec09wlxovioo/Casfhlow%20Forecast%20share.pbix?dl=0

Thank you very much in advance!

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User


@IAA 

I am not sure why you have a disconnected slicer for the category

Try this measure:

Measure = 
IF (
    
    COUNTROWS(
        INTERSECT(    
        ALLSELECTED ( 'Slicer Table'[Category] ),
        FILTERS('Value by date 2'[Category] )
    ))>0,
    CALCULATE (
        SUM ( 'Value by date 2'[Value] ),
        DATEADD ( DimDate[Date], - [Value Parameter], DAY )
    ),
    CALCULATE (
        SUM ( 'Value by date 2'[Value] ),
        DATEADD ( DimDate[Date], 0, DAY )
    )
)

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User


@IAA 

I am not sure why you have a disconnected slicer for the category

Try this measure:

Measure = 
IF (
    
    COUNTROWS(
        INTERSECT(    
        ALLSELECTED ( 'Slicer Table'[Category] ),
        FILTERS('Value by date 2'[Category] )
    ))>0,
    CALCULATE (
        SUM ( 'Value by date 2'[Value] ),
        DATEADD ( DimDate[Date], - [Value Parameter], DAY )
    ),
    CALCULATE (
        SUM ( 'Value by date 2'[Value] ),
        DATEADD ( DimDate[Date], 0, DAY )
    )
)

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you so so much @Fowmy ,

I was struggling for days to fix this and I am very happy that I finally got a way how this works. For learning purposes I will study the exact formula tomorrow, but now glad it works

 

You made my day!

@IAA 

Glad it worked!

 

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@IAA , Try like

Measure =
var _1 =ALLSELECTED('Slicer Table'[Category])
return
sumx( all('Slicer Table'[Category]) , if('Value by date 2'[Category] in _1 ,
CALCULATE (SUM( 'Value by date 2'[Value] ) , DATEADD(DimDate[Date],-[Value Parameter],DAY)),
CALCULATE (sum('Value by date 2'[Value]) , DATEADD(DimDate[Date],0,DAY))))

Thank you @amitchandak ,

Unfortunately, the if-statement does not work in this Dax formula. Any idea how to fix this?

IAA_0-1596118757186.png

 




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.