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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
danb
Resolver I
Resolver I

Nested If Statement in DAX pinging off of Text and Numerical Fields

Good morning Power BI experts! 
I Probably should be able to figure it out but i am unfortunately not. I have two tables. One is a simple volume report shown here:

Volume Report    
RegionItem CodeInvoice DateDCSupplierVolume
West12312/1/2021MiamiSupplier A876
East9871/13/2021San DiegoSupplier B219
North556/5/2021PittsburgSupplier F142
South4661/22/2020DenverSupplier Z630
West54289/8/2017ButteSupplier A721

 

I also have a "Project List" report that I want to query the Volume report to bring back the associated quantities. There can and will be overlap of volumes from the Volume Report going into the Project List. What I am struggling with is I have 4 different criteria:

RegionProjectItem CodeStart DateEnd DateSpecific DCSpecific SupplierVolumeNotes
WestApples12312/1/20211/1/2022   Want total volume for that region and Item Code between the two dates (all DCs and All Suppliers)
EastPears45610/1/2021 Supplier A  Want total volume for that region and item code between the two dates (all DCs but only "Supplier A")
WestApples1231/1/202212/31/2022 Miami Want total volume for that region and item code between the two dates (all Suppliers but only the "Miami" DC
EastPeaches9877/1/2021 Supplier CSan Diego Want total volume for that region, item code, specific DC and Specific Supplier between the two dates


1. If the Specific Supplier and Specific DC are populated on the Project List, i want the total volume for that region, item code, specific DC and Specific Supplier between the two dates

2. If the Specific Supplier is populated but not the Specific DC on the Project List, I want to bring back the total volume for that region, item code, specific Supplier across all DCs between the two dates

 

3. If the Specific DC is populated but not the Specific Supplier on the Project List, i want to bring back the total volume for that region, item code, specific DC across all Suppliers between the two dates

 

4. If neither the Specific Supplier or Specific DC are populated on the Project List, I want to bring back the total volume for that region, item code across all Suppliers and DCs between the two dates. 

 

Do i need to break the item list into different tables to seperate the different criteria or something else? 

Thanks!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I think you could do this with a measure along these lines:

 

 

TotalVolume =
VAR NoDC       = ISBLANK ( MAX ( Project[Specific DC] ) )
VAR NoSupplier = ISBLANK ( MAX ( Project[Specific Supplier] ) )
VAR StartDate  = MIN ( Project[Start Date] )
VAR EndDate    = MAX ( Project[End Date] )
RETURN
    CALCULATE (
        SUM ( Volume[Volume] ),
        Volume[Region] IN VALUES ( Project[Region] ),
        Volume[Item Code] IN VALUES ( Project[Item Code] ),
        Volume[Invoice Date] <= EndDate,
        Volume[Invoice Date] >= StartDate,
        FILTER (
            VALUES ( Volume[DC] ),
            NoDC || Volume[DC] IN VALUES ( Project[Specific DC] )
        ),
        FILTER (
            VALUES ( Volume[Supplier] ),
            NoSupplier || Volume[Supplier] IN VALUES ( Project[Specific Supplier] )
        )
    )

 

View solution in original post

2 REPLIES 2
danb
Resolver I
Resolver I

@AlexisOlson - Thanks for your help! It works!

AlexisOlson
Super User
Super User

I think you could do this with a measure along these lines:

 

 

TotalVolume =
VAR NoDC       = ISBLANK ( MAX ( Project[Specific DC] ) )
VAR NoSupplier = ISBLANK ( MAX ( Project[Specific Supplier] ) )
VAR StartDate  = MIN ( Project[Start Date] )
VAR EndDate    = MAX ( Project[End Date] )
RETURN
    CALCULATE (
        SUM ( Volume[Volume] ),
        Volume[Region] IN VALUES ( Project[Region] ),
        Volume[Item Code] IN VALUES ( Project[Item Code] ),
        Volume[Invoice Date] <= EndDate,
        Volume[Invoice Date] >= StartDate,
        FILTER (
            VALUES ( Volume[DC] ),
            NoDC || Volume[DC] IN VALUES ( Project[Specific DC] )
        ),
        FILTER (
            VALUES ( Volume[Supplier] ),
            NoSupplier || Volume[Supplier] IN VALUES ( Project[Specific Supplier] )
        )
    )

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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