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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
salim123
Frequent Visitor

Calculate a measure that checks if data is blank and If so use previous montavg to do calcuations

Hello every one,

So I am new to dax and I am writing this measure that calculates a weighted value (SUMPROD(volume, TS) divided bySUM(Volume)), but the problem is that TS values are not there every day, so I have to multiply the volume with TS avg of the previuos month, I see that my reasoning is right bu something dosen't seem to work.
Here is My measure :

TS Ponderee (Madcap) =

        DIVIDE(
            SUMX('all years data',
            var c=0
            return
                 if('all years data'[T/S]<>BLANK(),'all years data'[Vol L]*'all years data'[T/S], 'all years data'[Vol L]*[previous_month_ts])
            ),
            SUMX(
                'all years data', 'all years data'[Vol L]
            )
        )

The previous month measure:

previous_month_ts = Calculate(
                        [T/S avg],
                        DATEADD(DateAnalyse[Date],-30,DAY)
                    )

Here is a piece of my data , as you can T/S is not there every time:

salim123_2-1662733660534.png

And here what I get when I show data as a table:

salim123_3-1662733991713.png

Any remark would be helpful.
thank you

 

 

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@salim123 Can you post your data and measure formulas as text?



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank u Greg for ur feedback, I just did. thanks

Hi @salim123 ,

 

Has your problem been solved? If solved, please consider Accept it as the solution to help the other members find it more quickly.

 

Best regards,

Yadong Fang

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.