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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
adentler
Frequent Visitor

Visual with Slicer and Switch Help Request

Still very new to PBI / Dax and beating my head against a wall... I am creating a bar chart visual in PBI that will display the following on their own bar in the chart. I am looking to slice these bars (categories) based on contract year.  

Bars / Categories:

  1. Invoices Submitted
    • (Sum of Amount Where Submitted date is not blank)
  2. Invoices Accepted
    •  (Sum of Amount Where Submitted date is not blank AND Accepted Date is not blank)
  3. Invoices Deposited
    •  (Sum of Amount Where Deposited date, Submitted date, AND Accepted Date is not blank)
  4. Invoices Paid
    • (Sum of Amount Where Paid date, Deposited date, Submitted date, AND Accepted Date is not blank)

This is a customers tracking spreadsheet that I can transform data upon import, but cannot reformat. As you can see, they are tracking invoice progression based on date. They need to know how much has been submitted, accepted, deposited, and paid. Additionally, they want to be able to slice these bars based on pre-defined contract years (originally they wanted standard YTD, MTD, etc.. and I had this working but cannot get it to work now with the contract years).

 

This is what I have thus far and I am open to any help anyone provides!

 

Period Table: 

  • Using this as my slicer and it allows for Select All or Contract Year Options with Multi-Select)

ContractYear_ID

ContractYear

1

Base

2

Year1

3

Year2

4

Year3

5

Year4

 

Date: 

Date =

    CALENDAR(DATE(2023, 1, 1), DATE(2029, 6, 30))

 

Date

ContractYear_ID

30-Jun-25

1

29-June25

1

etc..

etc..

 

Measure : Invoices Submitted

  • (other categories have the same measures referencing their correct date field. Ie: [Accepted Date], [Deposited Date] etc.)

 

Invoices Submitted = CALCULATE(

    SUM(' Invoices'[Amount ($)]),

    FILTER(

        ' Invoices',

        NOT(ISBLANK('Invoices'[Submitted Date])

    )

))

 

 

 

Previous Switch (obviously won’t work)

 

"Period Invoices Submitted =

SWITCH([Selected Period],

1, IF(ISBLANK(TOTALMTD([Invoices Submitted], DATESMTD(ALL('Invoices'[Submitted Date])))), 0, TOTALMTD([Invoices Submitted], DATESMTD(ALL('Invoices'[Submitted Date])))),

2, IF(ISBLANK(TOTALQTD([Invoices Submitted], DATESQTD(ALL('Invoices'[Submitted Date])))), 0, TOTALQTD([Invoices Submitted], DATESQTD(ALL('Invoices'[Submitted Date])))),

3, IF(ISBLANK(TOTALYTD([Invoices Submitted], DATESYTD(ALL('Invoices'[Submitted Date])))), 0, TOTALYTD([Invoices Submitted], DATESYTD(ALL('Invoices'[Submitted Date])))),

4, IF(ISBLANK(TOTALYTD([Invoices Submitted], PREVIOUSYEAR(DATESYTD(ALL('Invoices'[Submitted Date]))))), 0, TOTALQTD([Invoices Submitted], DATESQTD(ALL('Invoices'[Submitted Date])))),

5, [Invoices Submitted]

)"

 

Obviously the switch above will not work as it references pre-defined functions of TOTALYTD, DATESYTD, etc.

 

GOAL:

To create a dynamic bar chart that will represent the totals for each catergory based on the slicer selection.. with the ability to drill down and see the record data that the totals were derived from.

 

Mockup: (When Base Year is Selected)

 

adentler_0-1756318629857.png

 

When Year 1 is selected: (Year 1 is the current year)

adentler_1-1756318749003.png

 

Thank you in advance for any guidance provided!!

1 ACCEPTED SOLUTION
techies
Super User
Super User

Hi @adentler as i understand, please try this,

 

after defining your measures for example, like this

Invoices Accepted =
CALCULATE (
SUM ( Invoices[Amount ($)] ),
NOT ISBLANK ( Invoices[Submitted Date] ),
NOT ISBLANK ( Invoices[Accepted Date] ),
TREATAS ( VALUES ( Period[ContractYear_ID] ), 'Date'[ContractYear_ID] ),
USERELATIONSHIP ( Invoices[Accepted Date], 'Date'[Date] )
)

 

repeat for submitted, deposited and so on

 

then create a disconnected table

 

Category = DATATABLE (
"Category", STRING,
{
{ "Submitted" },
{ "Accepted" },
{ "Deposited" },
{ "Paid" }
}
)

 

and the measure  as this Invoice Amount by Category =
SWITCH (
SELECTEDVALUE ( Category[Category] ),
"Submitted", [Invoices Submitted],
"Accepted", [Invoices Accepted],
"Deposited", [Invoices Deposited],
"Paid", [Invoices Paid]
)

 

 

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

View solution in original post

2 REPLIES 2
techies
Super User
Super User

Hi @adentler as i understand, please try this,

 

after defining your measures for example, like this

Invoices Accepted =
CALCULATE (
SUM ( Invoices[Amount ($)] ),
NOT ISBLANK ( Invoices[Submitted Date] ),
NOT ISBLANK ( Invoices[Accepted Date] ),
TREATAS ( VALUES ( Period[ContractYear_ID] ), 'Date'[ContractYear_ID] ),
USERELATIONSHIP ( Invoices[Accepted Date], 'Date'[Date] )
)

 

repeat for submitted, deposited and so on

 

then create a disconnected table

 

Category = DATATABLE (
"Category", STRING,
{
{ "Submitted" },
{ "Accepted" },
{ "Deposited" },
{ "Paid" }
}
)

 

and the measure  as this Invoice Amount by Category =
SWITCH (
SELECTEDVALUE ( Category[Category] ),
"Submitted", [Invoices Submitted],
"Accepted", [Invoices Accepted],
"Deposited", [Invoices Deposited],
"Paid", [Invoices Paid]
)

 

 

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

Thank you! This seems to be working. I sincerely appreciate your assistance!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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