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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
mayurbajaj
New Member

Need Help with Virtual Tables

Hi ALl,

I got two tables, one of which had some invoices for an account with multiple start dates and end dates (Table Bill) and another table which has the bill frequency (Table Account).

I want to find out if any account has not received any invoices in time or not.

As an example, 

Max Invoice Start Date: 01/03/2024

Max Invoice End Date: 31/03/2024

Account Billing Frequency: Monthly (there are multiple valies here)

Final Output: If the account is set up as Monthly billing frequency i want to add 45 days into the Max End Date giving me an expected date of 15/05/2024 by which i should have received the invoice for April Period. After 15/05/2024, it should start to get reported and by how many days it's late.

 

I want to be able to do this using virtual tables within a DAX Measure rather than creating seperate tables for this.

 

Any suggestions.

 

4 REPLIES 4
Anonymous
Not applicable

Hi @mayurbajaj ,

 

Please provide sample data in table format and show your expected results.

 

Best regards,
Community Support Team_ Scott Chang

These are my 2 tables:

mayurbajaj_0-1716440083360.png

So far i ave tried this

LateInvoiceDays =
VAR MaxEndDate = MAX('Bill Header'[Bill End Date])
VAR MaxStartDate = MAX('Bill Header'[Bill Start Date])
VAR BillingFrequency = MAX('Account'[Bill Cycle])  // Assuming BillingFrequency is a single value for each account

// Calculate expected invoice date based on billing frequency
VAR ExpectedInvoiceDate =
    SWITCH (
        BillingFrequency,
        "Monthly", EDATE(MaxEndDate, 45),  // Add 45 days for monthly billing frequency
        "Quarterly", EDATE(MaxEndDate, 105),  // Add 105 days for quarterly billing frequency
        "Bi-Monthly", EDATE(MaxEndDate, 75),  // Add 75 days for quarterly billing frequency
        // Add more cases for other billing frequencies if needed
        BLANK()  // Return BLANK if BillingFrequency is not recognized
    )

// Calculate late days
VAR CurrentDate = TODAY()
RETURN
    IF (
        CurrentDate > ExpectedInvoiceDate,
        DATEDIFF(CurrentDate, ExpectedInvoiceDate, DAY),  // Calculate the difference in days
        0  // If not late, return 0 days
    )
 
However it's giving me an error
mayurbajaj_1-1716440124307.png

 

Any help would be appreciated

 
Anonymous
Not applicable

Hi @mayurbajaj ,

 

I guess the problem is with the switch statement, I didn't find information about BillingFrequency in your screenshot.

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

The Billing Frequency is basially 'BILL CYCLE' within the screen shot

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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